[vcpkg-autocomplete] Add edit completion
MODIFY
include/vcpkg/commands.h
include/vcpkg/commands.h
@@ -38,6 +38,7 @@ namespace vcpkg::Commands
namespace Edit
{
+ extern const CommandStructure COMMAND_STRUCTURE;
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths);
}

MODIFY
include/vcpkg/install.h
include/vcpkg/install.h
@@ -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);
}

MODIFY
include/vcpkg/remove.h
include/vcpkg/remove.h
@@ -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);

MODIFY
src/vcpkg/commands.autocomplete.cpp
src/vcpkg/commands.autocomplete.cpp
@@ -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)

MODIFY
src/vcpkg/commands.edit.cpp
src/vcpkg/commands.edit.cpp
#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";

MODIFY
src/vcpkg/install.cpp
src/vcpkg/install.cpp
@@ -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,

MODIFY
src/vcpkg/remove.cpp
src/vcpkg/remove.cpp
@@ -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,

[vcpkg-autocomplete] Add edit completion