`vcpkg ci` Use switch-case
MODIFY
src/commands_ci.cpp
src/commands_ci.cpp
@@ -56,12 +56,13 @@ namespace vcpkg::Commands::CI
try
{
- if (action.plan.plan_type == InstallPlanType::ALREADY_INSTALLED)
+ switch (action.plan.plan_type)
{
+ case InstallPlanType::ALREADY_INSTALLED:
results.back() = BuildResult::SUCCEEDED;
System::println(System::Color::success, "Package %s is already installed", display_name);
- }
- else if (action.plan.plan_type == InstallPlanType::BUILD_AND_INSTALL)
+ break;
+ case InstallPlanType::BUILD_AND_INSTALL:
{
const BuildResult result = Commands::Build::build_package(action.plan.source_pgh.value_or_exit(VCPKG_LINE_INFO),
action.spec,
@@ -78,16 +79,17 @@ namespace vcpkg::Commands::CI
const BinaryParagraph bpgh = Paragraphs::try_load_cached_package(paths, action.spec).value_or_exit(VCPKG_LINE_INFO);
Install::install_package(paths, bpgh, &status_db);
System::println(System::Color::success, "Package %s is installed", display_name);
+ break;
}
- else if (action.plan.plan_type == InstallPlanType::INSTALL)
- {
+ case InstallPlanType::INSTALL:
results.back() = BuildResult::SUCCEEDED;
Install::install_package(paths, action.plan.binary_pgh.value_or_exit(VCPKG_LINE_INFO), &status_db);
System::println(System::Color::success, "Package %s is installed from cache", display_name);
- }
- else
+ break;
+ default:
Checks::unreachable(VCPKG_LINE_INFO);
}
+ }
catch (const std::exception& e)
{
System::println(System::Color::error, "Error: Could not install package %s: %s", action.spec.display_name(), e.what());

`vcpkg ci` Use switch-case