diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-03-29 17:45:53 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-03-31 16:15:05 -0700 |
| commit | 14297a5bd916bbe41852625dd57637c92fb79c06 (patch) | |
| tree | 8e84b94d896bd3dadfc4c3c71055ff596d775c8b /toolsrc/src/commands_remove.cpp | |
| parent | ee75fe6330d14401b06d74648b29afc161943d54 (diff) | |
| download | vcpkg-14297a5bd916bbe41852625dd57637c92fb79c06.tar.gz vcpkg-14297a5bd916bbe41852625dd57637c92fb79c06.zip | |
`remove`: Add --dry-run option
Diffstat (limited to 'toolsrc/src/commands_remove.cpp')
| -rw-r--r-- | toolsrc/src/commands_remove.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/toolsrc/src/commands_remove.cpp b/toolsrc/src/commands_remove.cpp index e6677d740..9f4c76b11 100644 --- a/toolsrc/src/commands_remove.cpp +++ b/toolsrc/src/commands_remove.cpp @@ -13,6 +13,7 @@ namespace vcpkg::Commands::Remove static const std::string OPTION_PURGE = "--purge"; static const std::string OPTION_RECURSE = "--recurse"; + static const std::string OPTION_DRY_RUN = "--dry-run"; static void delete_directory(const fs::path& directory) { @@ -147,19 +148,19 @@ namespace vcpkg::Commands::Remove sort_packages_by_name(&remove); System::println("The following packages will be removed:\n%s", Strings::join("\n", remove, [](const package_spec_with_remove_plan* p) - { - if (p->plan.request_type == Dependencies::request_type::AUTO_SELECTED) - { - return " * " + p->spec.toString(); - } - - if (p->plan.request_type == Dependencies::request_type::USER_REQUESTED) - { - return " " + p->spec.toString(); - } - - Checks::unreachable(VCPKG_LINE_INFO); - })); + { + if (p->plan.request_type == Dependencies::request_type::AUTO_SELECTED) + { + return " * " + p->spec.toString(); + } + + if (p->plan.request_type == Dependencies::request_type::USER_REQUESTED) + { + return " " + p->spec.toString(); + } + + Checks::unreachable(VCPKG_LINE_INFO); + })); } } @@ -169,15 +170,20 @@ namespace vcpkg::Commands::Remove args.check_min_arg_count(1, example); std::vector<package_spec> specs = Input::check_and_get_package_specs(args.command_arguments, default_target_triplet, example); Input::check_triplets(specs, paths); - const std::unordered_set<std::string> options = args.check_and_get_optional_command_arguments({ OPTION_PURGE, OPTION_RECURSE }); + const std::unordered_set<std::string> options = args.check_and_get_optional_command_arguments({ OPTION_PURGE, OPTION_RECURSE, OPTION_DRY_RUN }); const bool alsoRemoveFolderFromPackages = options.find(OPTION_PURGE) != options.end(); const bool isRecursive = options.find(OPTION_RECURSE) != options.end(); + const bool dryRun = options.find(OPTION_DRY_RUN) != options.end(); auto status_db = database_load_check(paths); const std::vector<package_spec_with_remove_plan> remove_plan = Dependencies::create_remove_plan(specs, status_db); Checks::check_exit(VCPKG_LINE_INFO, !remove_plan.empty(), "Remove plan cannot be empty"); print_plan(remove_plan); + if (dryRun) + { + Checks::exit_success(VCPKG_LINE_INFO); + } const bool has_non_user_requested_packages = std::find_if(remove_plan.cbegin(), remove_plan.cend(), [](const package_spec_with_remove_plan& package)-> bool { |
