diff options
| author | Jan HrubĂ˝ <jhruby.web@gmail.com> | 2017-03-13 08:56:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-13 08:56:05 +0100 |
| commit | 665f4118f603c5858217ed7a2f2f824b18ff4fc5 (patch) | |
| tree | f0167041edf71e90f2331b5025f603392a8de67a /toolsrc/src/commands_owns.cpp | |
| parent | 1bec0fcb73073b5b1719f454c368a63f1bff625e (diff) | |
| parent | 1c9873a0daf625f67474aaf3e163c592c27ecb65 (diff) | |
| download | vcpkg-665f4118f603c5858217ed7a2f2f824b18ff4fc5.tar.gz vcpkg-665f4118f603c5858217ed7a2f2f824b18ff4fc5.zip | |
Merge pull request #1 from Microsoft/master
pull
Diffstat (limited to 'toolsrc/src/commands_owns.cpp')
| -rw-r--r-- | toolsrc/src/commands_owns.cpp | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/toolsrc/src/commands_owns.cpp b/toolsrc/src/commands_owns.cpp index 19c0a8dc6..16bb986e2 100644 --- a/toolsrc/src/commands_owns.cpp +++ b/toolsrc/src/commands_owns.cpp @@ -1,18 +1,33 @@ +#include "pch.h" #include "vcpkg_Commands.h" #include "vcpkg_System.h" -#include "vcpkg.h" +#include "vcpkglib.h" -namespace vcpkg +namespace vcpkg::Commands::Owns { - void owns_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) + static void search_file(const vcpkg_paths& paths, const std::string& file_substr, const StatusParagraphs& status_db) { - args.check_max_args(1); - if (args.command_arguments.size() == 0) + const std::vector<StatusParagraph_and_associated_files> installed_files = get_installed_files(paths, status_db); + for (const StatusParagraph_and_associated_files& pgh_and_file : installed_files) { - System::println(System::color::error, "Error: owns requires a pattern to search for as the first argument."); - print_example("owns .dll"); - exit(EXIT_FAILURE); + const StatusParagraph& pgh = pgh_and_file.pgh; + + for (const std::string& file : pgh_and_file.files) + { + if (file.find(file_substr) != std::string::npos) + { + System::println("%s: %s", pgh.package.displayname(), file); + } + } } + } + + void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) + { + static const std::string example = Strings::format("The argument should be a pattern to search for. %s", Commands::Help::create_example_string("owns zlib.dll")); + args.check_exact_arg_count(1, example); + args.check_and_get_optional_command_arguments({}); + StatusParagraphs status_db = database_load_check(paths); search_file(paths, args.command_arguments[0], status_db); exit(EXIT_SUCCESS); |
