diff options
| author | Maria Tavlaki <mariataylaki@hotmail.com> | 2017-10-02 00:03:39 +0300 |
|---|---|---|
| committer | Maria Tavlaki <mariataylaki@hotmail.com> | 2017-10-02 01:24:19 +0300 |
| commit | 7c2239f980197096a13e8fb4b96297b08616eb78 (patch) | |
| tree | efdbb0f597d3fdb99b70d8e65aefe221734596cb /toolsrc/src/commands_autocomplete.cpp | |
| parent | fe89e72e9565f0515834b925f015fe19324c38da (diff) | |
| download | vcpkg-7c2239f980197096a13e8fb4b96297b08616eb78.tar.gz vcpkg-7c2239f980197096a13e8fb4b96297b08616eb78.zip | |
Autocomplete: check if first argument is "install"
Diffstat (limited to 'toolsrc/src/commands_autocomplete.cpp')
| -rw-r--r-- | toolsrc/src/commands_autocomplete.cpp | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/toolsrc/src/commands_autocomplete.cpp b/toolsrc/src/commands_autocomplete.cpp index a67113aff..013cea320 100644 --- a/toolsrc/src/commands_autocomplete.cpp +++ b/toolsrc/src/commands_autocomplete.cpp @@ -8,6 +8,23 @@ namespace vcpkg::Commands::Autocomplete { + std::vector<std::string> autocomplete_install( + const std::vector<std::unique_ptr<SourceControlFile>>& source_paragraphs, const std::string& start_with) + { + std::vector<std::string> results; + const auto& istartswith = Strings::case_insensitive_ascii_starts_with; + + for (const auto& source_control_file : source_paragraphs) + { + auto&& sp = *source_control_file->core_paragraph; + + if (istartswith(sp.name, start_with)) + { + results.push_back(sp.name); + } + } + return results; + } void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) { static const std::string EXAMPLE = @@ -21,27 +38,15 @@ namespace vcpkg::Commands::Autocomplete const std::string requested_command = args.command_arguments.at(0); const std::string start_with = args.command_arguments.size() > 1 ? args.command_arguments.at(1) : Strings::EMPTY; - - auto sources_and_errors = Paragraphs::try_load_all_ports(paths.get_filesystem(), paths.ports); - auto& source_paragraphs = sources_and_errors.paragraphs; - - const auto& istartswith = Strings::case_insensitive_ascii_starts_with; - std::vector<std::string> results; - for (const auto& source_control_file : source_paragraphs) + if (requested_command == "install") { - auto&& sp = *source_control_file->core_paragraph; + auto sources_and_errors = Paragraphs::try_load_all_ports(paths.get_filesystem(), paths.ports); + auto& source_paragraphs = sources_and_errors.paragraphs; - if (istartswith(sp.name, start_with)) - { - results.push_back(sp.name); - } + results = autocomplete_install(source_paragraphs, start_with); } - System::println(Strings::join(" ", results)); - - auto all_ports = Paragraphs::try_load_all_ports(paths.get_filesystem(), paths.ports); - Checks::exit_success(VCPKG_LINE_INFO); } } |
