mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-31 05:03:22 +08:00
autocomplete
Consider private commands if no public commands match
This commit is contained in:
parent
7ed8d4f75e
commit
947c6cac33
@ -39,7 +39,8 @@ namespace vcpkg::Commands::Autocomplete
|
|||||||
{
|
{
|
||||||
const std::string requested_command = match[1].str();
|
const std::string requested_command = match[1].str();
|
||||||
|
|
||||||
std::vector<std::string> valid_commands = {
|
// First try public commands
|
||||||
|
std::vector<std::string> public_commands = {
|
||||||
"install",
|
"install",
|
||||||
"search",
|
"search",
|
||||||
"remove",
|
"remove",
|
||||||
@ -57,11 +58,31 @@ namespace vcpkg::Commands::Autocomplete
|
|||||||
"contact",
|
"contact",
|
||||||
};
|
};
|
||||||
|
|
||||||
Util::unstable_keep_if(valid_commands, [&](const std::string& s) {
|
Util::unstable_keep_if(public_commands, [&](const std::string& s) {
|
||||||
return Strings::case_insensitive_ascii_starts_with(s, requested_command);
|
return Strings::case_insensitive_ascii_starts_with(s, requested_command);
|
||||||
});
|
});
|
||||||
|
|
||||||
output_sorted_results_and_exit(VCPKG_LINE_INFO, std::move(valid_commands));
|
if (!public_commands.empty())
|
||||||
|
{
|
||||||
|
output_sorted_results_and_exit(VCPKG_LINE_INFO, std::move(public_commands));
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no public commands match, try private commands
|
||||||
|
std::vector<std::string> private_commands = {
|
||||||
|
"build",
|
||||||
|
"buildexternal",
|
||||||
|
"ci",
|
||||||
|
"depend-info",
|
||||||
|
"env",
|
||||||
|
"import",
|
||||||
|
"portsdiff",
|
||||||
|
};
|
||||||
|
|
||||||
|
Util::unstable_keep_if(private_commands, [&](const std::string& s) {
|
||||||
|
return Strings::case_insensitive_ascii_starts_with(s, requested_command);
|
||||||
|
});
|
||||||
|
|
||||||
|
output_sorted_results_and_exit(VCPKG_LINE_INFO, std::move(private_commands));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handles vcpkg install package:<triplet>
|
// Handles vcpkg install package:<triplet>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user