diff options
| author | Maria Tavlaki <mariataylaki@hotmail.com> | 2017-10-01 23:26:36 +0300 |
|---|---|---|
| committer | Maria Tavlaki <mariataylaki@hotmail.com> | 2017-10-02 01:24:18 +0300 |
| commit | fe89e72e9565f0515834b925f015fe19324c38da (patch) | |
| tree | 470969a1a78e8ede012a412bfae62643e22880bc | |
| parent | b3e06443eab560d5de848f2a066e1baa477fa57b (diff) | |
| download | vcpkg-fe89e72e9565f0515834b925f015fe19324c38da.tar.gz vcpkg-fe89e72e9565f0515834b925f015fe19324c38da.zip | |
Autocomplete: handle arguments
| -rw-r--r-- | toolsrc/src/commands_autocomplete.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/toolsrc/src/commands_autocomplete.cpp b/toolsrc/src/commands_autocomplete.cpp index 71154445d..a67113aff 100644 --- a/toolsrc/src/commands_autocomplete.cpp +++ b/toolsrc/src/commands_autocomplete.cpp @@ -14,9 +14,34 @@ namespace vcpkg::Commands::Autocomplete Strings::format("The argument should be a command line to autocomplete.\n%s", Commands::Help::create_example_string("autocomplete install z")); - args.check_max_arg_count(1, EXAMPLE); + args.check_min_arg_count(1, EXAMPLE); + args.check_max_arg_count(2, EXAMPLE); args.check_and_get_optional_command_arguments({}); + 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) + { + auto&& sp = *source_control_file->core_paragraph; + + if (istartswith(sp.name, start_with)) + { + results.push_back(sp.name); + } + } + + System::println(Strings::join(" ", results)); + + auto all_ports = Paragraphs::try_load_all_ports(paths.get_filesystem(), paths.ports); + Checks::exit_success(VCPKG_LINE_INFO); } } |
