mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-25 08:49:01 +08:00
[vcpkg-autocomplete] Add edit completion
This commit is contained in:
parent
b73327558b
commit
58fd38c820
@ -38,6 +38,7 @@ namespace vcpkg::Commands
|
||||
|
||||
namespace Edit
|
||||
{
|
||||
extern const CommandStructure COMMAND_STRUCTURE;
|
||||
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths);
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ namespace vcpkg::Install
|
||||
const VcpkgPaths& paths,
|
||||
StatusParagraphs& status_db);
|
||||
|
||||
extern const CommandStructure INSTALL_COMMAND_STRUCTURE;
|
||||
extern const CommandStructure COMMAND_STRUCTURE;
|
||||
|
||||
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace vcpkg::Remove
|
||||
const Purge purge,
|
||||
StatusParagraphs& status_db);
|
||||
|
||||
extern const CommandStructure REMOVE_COMMAND_STRUCTURE;
|
||||
extern const CommandStructure COMMAND_STRUCTURE;
|
||||
|
||||
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet);
|
||||
void remove_package(const VcpkgPaths& paths, const PackageSpec& spec, StatusParagraphs* status_db);
|
||||
|
@ -97,8 +97,9 @@ namespace vcpkg::Commands::Autocomplete
|
||||
const CommandStructure& structure;
|
||||
};
|
||||
static constexpr CommandEntry commands[] = {
|
||||
{R"###(^install\s(.*\s|)(\S*)$)###", Install::INSTALL_COMMAND_STRUCTURE},
|
||||
{R"###(^remove\s(.*\s|)(\S*)$)###", Remove::REMOVE_COMMAND_STRUCTURE},
|
||||
{R"###(^install\s(.*\s|)(\S*)$)###", Install::COMMAND_STRUCTURE},
|
||||
{R"###(^edit\s(.*\s|)(\S*)$)###", Edit::COMMAND_STRUCTURE},
|
||||
{R"###(^remove\s(.*\s|)(\S*)$)###", Remove::COMMAND_STRUCTURE},
|
||||
};
|
||||
|
||||
for (auto&& command : commands)
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <vcpkg/commands.h>
|
||||
#include <vcpkg/help.h>
|
||||
#include <vcpkg/input.h>
|
||||
#include <vcpkg/paragraphs.h>
|
||||
|
||||
namespace vcpkg::Commands::Edit
|
||||
{
|
||||
@ -30,10 +31,32 @@ namespace vcpkg::Commands::Edit
|
||||
return output;
|
||||
}
|
||||
|
||||
static const std::string OPTION_BUILDTREES = "--buildtrees";
|
||||
|
||||
static const std::array<std::string, 1> SWITCHES = {
|
||||
OPTION_BUILDTREES,
|
||||
};
|
||||
static const std::array<std::string, 0> SETTINGS;
|
||||
|
||||
static std::vector<std::string> valid_arguments(const VcpkgPaths& paths)
|
||||
{
|
||||
auto sources_and_errors = Paragraphs::try_load_all_ports(paths.get_filesystem(), paths.ports);
|
||||
|
||||
return Util::fmap(sources_and_errors.paragraphs,
|
||||
[](auto&& pgh) -> std::string { return pgh->core_paragraph->name; });
|
||||
}
|
||||
|
||||
const CommandStructure COMMAND_STRUCTURE = {
|
||||
"edit zlib",
|
||||
1,
|
||||
1,
|
||||
SWITCHES,
|
||||
SETTINGS,
|
||||
&valid_arguments,
|
||||
};
|
||||
|
||||
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
|
||||
{
|
||||
static const std::string OPTION_BUILDTREES = "--buildtrees";
|
||||
|
||||
static const fs::path VS_CODE_INSIDERS = fs::path{"Microsoft VS Code Insiders"} / "Code - Insiders.exe";
|
||||
static const fs::path VS_CODE = fs::path{"Microsoft VS Code"} / "Code.exe";
|
||||
|
||||
|
@ -548,7 +548,7 @@ namespace vcpkg::Install
|
||||
[](auto&& pgh) -> std::string { return pgh->core_paragraph->name; });
|
||||
}
|
||||
|
||||
const CommandStructure INSTALL_COMMAND_STRUCTURE = {
|
||||
const CommandStructure COMMAND_STRUCTURE = {
|
||||
"install zlib zlib:x64-windows curl boost",
|
||||
1,
|
||||
SIZE_MAX,
|
||||
|
@ -186,7 +186,7 @@ namespace vcpkg::Remove
|
||||
return Util::fmap(installed_packages, [](auto&& pgh) -> std::string { return pgh->package.spec.to_string(); });
|
||||
}
|
||||
|
||||
const CommandStructure REMOVE_COMMAND_STRUCTURE = {
|
||||
const CommandStructure COMMAND_STRUCTURE = {
|
||||
"remove zlib zlib:x64-windows curl boost",
|
||||
1,
|
||||
SIZE_MAX,
|
||||
|
Loading…
Reference in New Issue
Block a user