diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-04-07 15:17:10 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-04-07 15:45:14 -0700 |
| commit | fabeefdb14f3ea4b21e42fddced41e96a09f6df5 (patch) | |
| tree | 4e83ad67eed35f05fd428386001867d3ef82634f /toolsrc/src/commands_install.cpp | |
| parent | 687e1d6a1baf141fffe490c23e3fe3512dec3840 (diff) | |
| download | vcpkg-fabeefdb14f3ea4b21e42fddced41e96a09f6df5.tar.gz vcpkg-fabeefdb14f3ea4b21e42fddced41e96a09f6df5.zip | |
Use switch-case
Diffstat (limited to 'toolsrc/src/commands_install.cpp')
| -rw-r--r-- | toolsrc/src/commands_install.cpp | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/toolsrc/src/commands_install.cpp b/toolsrc/src/commands_install.cpp index f5e5b42c0..549a2f91d 100644 --- a/toolsrc/src/commands_install.cpp +++ b/toolsrc/src/commands_install.cpp @@ -283,39 +283,40 @@ namespace vcpkg::Commands::Install { try { - if (action.plan.plan_type == InstallPlanType::ALREADY_INSTALLED) + switch (action.plan.plan_type) { - if (std::find(specs.begin(), specs.end(), action.spec) != specs.end()) - { - System::println(System::Color::success, "Package %s is already installed", action.spec); - } + case InstallPlanType::ALREADY_INSTALLED: + if (std::find(specs.begin(), specs.end(), action.spec) != specs.end()) + { + System::println(System::Color::success, "Package %s is already installed", action.spec); + } + break; + case InstallPlanType::BUILD_AND_INSTALL: + { + const Build::BuildResult result = Commands::Build::build_package(action.plan.source_pgh.value_or_exit(VCPKG_LINE_INFO), + action.spec, + paths, + paths.port_dir(action.spec), + status_db); + if (result != Build::BuildResult::SUCCEEDED) + { + System::println(System::Color::error, Build::create_error_message(result, action.spec)); + System::println(Build::create_user_troubleshooting_message(action.spec)); + Checks::exit_fail(VCPKG_LINE_INFO); + } + const BinaryParagraph bpgh = Paragraphs::try_load_cached_package(paths, action.spec).value_or_exit(VCPKG_LINE_INFO); + System::println("Installing package %s... ", action.spec); + install_package(paths, bpgh, &status_db); + System::println(System::Color::success, "Installing package %s... done", action.spec); + } + case InstallPlanType::INSTALL: + System::println("Installing package %s... ", action.spec); + install_package(paths, action.plan.binary_pgh.value_or_exit(VCPKG_LINE_INFO), &status_db); + System::println(System::Color::success, "Installing package %s... done", action.spec); + break; + default: + Checks::unreachable(VCPKG_LINE_INFO); } - else if (action.plan.plan_type == InstallPlanType::BUILD_AND_INSTALL) - { - const Build::BuildResult result = Commands::Build::build_package(action.plan.source_pgh.value_or_exit(VCPKG_LINE_INFO), - action.spec, - paths, - paths.port_dir(action.spec), - status_db); - if (result != Build::BuildResult::SUCCEEDED) - { - System::println(System::Color::error, Build::create_error_message(result, action.spec)); - System::println(Build::create_user_troubleshooting_message(action.spec)); - Checks::exit_fail(VCPKG_LINE_INFO); - } - const BinaryParagraph bpgh = Paragraphs::try_load_cached_package(paths, action.spec).value_or_exit(VCPKG_LINE_INFO); - System::println("Installing package %s... ", action.spec); - install_package(paths, bpgh, &status_db); - System::println(System::Color::success, "Installing package %s... done", action.spec); - } - else if (action.plan.plan_type == InstallPlanType::INSTALL) - { - System::println("Installing package %s... ", action.spec); - install_package(paths, action.plan.binary_pgh.value_or_exit(VCPKG_LINE_INFO), &status_db); - System::println(System::Color::success, "Installing package %s... done", action.spec); - } - else - Checks::unreachable(VCPKG_LINE_INFO); } catch (const std::exception& e) { |
