[vcpkg-autocomplete] Add edit completion

This commit is contained in:
Robert Schumacher 2017-10-14 02:16:55 -07:00
parent b73327558b
commit 58fd38c820
7 changed files with 33 additions and 8 deletions

View File

@ -38,6 +38,7 @@ namespace vcpkg::Commands
namespace Edit
{
extern const CommandStructure COMMAND_STRUCTURE;
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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)

View File

@ -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;
}
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
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 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";

View File

@ -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,

View File

@ -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,