aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-01-12 22:03:57 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2017-01-12 22:03:57 -0800
commitcc8851144a871931b93d84bd962364159ad1c424 (patch)
treedb9511533d051dcbcd3c8a2edc6854aa4ff7e9e7
parent8e1ed2c9a95fa5b9e0bb0a9849a6e20878696f8c (diff)
downloadvcpkg-cc8851144a871931b93d84bd962364159ad1c424.tar.gz
vcpkg-cc8851144a871931b93d84bd962364159ad1c424.zip
Reorganize commands, each in its own namespace
Additionally, functions related to a command can now live in the same namespace
-rw-r--r--toolsrc/include/vcpkg_Commands.h123
-rw-r--r--toolsrc/src/commands_available_commands.cpp38
-rw-r--r--toolsrc/src/commands_build.cpp10
-rw-r--r--toolsrc/src/commands_build_external.cpp10
-rw-r--r--toolsrc/src/commands_cache.cpp6
-rw-r--r--toolsrc/src/commands_contact.cpp4
-rw-r--r--toolsrc/src/commands_create.cpp6
-rw-r--r--toolsrc/src/commands_edit.cpp6
-rw-r--r--toolsrc/src/commands_hash.cpp6
-rw-r--r--toolsrc/src/commands_help.cpp80
-rw-r--r--toolsrc/src/commands_helpers.cpp48
-rw-r--r--toolsrc/src/commands_import.cpp6
-rw-r--r--toolsrc/src/commands_install.cpp8
-rw-r--r--toolsrc/src/commands_integrate.cpp4
-rw-r--r--toolsrc/src/commands_list.cpp6
-rw-r--r--toolsrc/src/commands_owns.cpp6
-rw-r--r--toolsrc/src/commands_portsdiff.cpp6
-rw-r--r--toolsrc/src/commands_remove.cpp6
-rw-r--r--toolsrc/src/commands_search.cpp6
-rw-r--r--toolsrc/src/commands_update.cpp4
-rw-r--r--toolsrc/src/commands_version.cpp4
-rw-r--r--toolsrc/src/main.cpp4
-rw-r--r--toolsrc/src/vcpkg_Input.cpp2
-rw-r--r--toolsrc/src/vcpkg_cmd_arguments.cpp6
-rw-r--r--toolsrc/vcpkg/vcpkg.vcxproj1
-rw-r--r--toolsrc/vcpkg/vcpkg.vcxproj.filters3
26 files changed, 234 insertions, 175 deletions
diff --git a/toolsrc/include/vcpkg_Commands.h b/toolsrc/include/vcpkg_Commands.h
index 6b4941cc1..8d772b255 100644
--- a/toolsrc/include/vcpkg_Commands.h
+++ b/toolsrc/include/vcpkg_Commands.h
@@ -5,40 +5,110 @@
namespace vcpkg::Commands
{
- extern const char*const INTEGRATE_COMMAND_HELPSTRING;
-
using command_type_a = void(*)(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
using command_type_b = void(*)(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
using command_type_c = void(*)(const vcpkg_cmd_arguments& args);
- void update_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ namespace Build
+ {
+ void build_package(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir);
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
+ }
+
+ namespace BuildExternal
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
+ }
+
+ namespace Install
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
+ }
+
+ namespace Remove
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
+ }
+
+ namespace Update
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace Create
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace Edit
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace Search
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace List
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace Import
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace Owns
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace Cache
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace Integrate
+ {
+ extern const char*const INTEGRATE_COMMAND_HELPSTRING;
+
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
+
+ namespace PortsDiff
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ }
- void build_internal(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir);
- void build_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
- void build_external_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
- void install_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
- void remove_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
+ namespace Help
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
- void edit_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
- void create_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ void help_topic_valid_triplet(const vcpkg_paths& paths);
- void search_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
- void list_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
- void import_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
- void owns_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ void print_usage();
- void cache_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ void print_example(const std::string& command_and_arguments);
- void integrate_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ std::string create_example_string(const std::string& command_and_arguments);
+ }
- void portsdiff_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
+ namespace Version
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args);
+ }
- void help_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
- void help_topic_valid_triplet(const vcpkg_paths& paths);
+ namespace Contact
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args);
+ }
- void version_command(const vcpkg_cmd_arguments& args);
- void contact_command(const vcpkg_cmd_arguments& args);
- void hash_command(const vcpkg_cmd_arguments& args);
+ namespace Hash
+ {
+ void perform_and_exit(const vcpkg_cmd_arguments& args);
+ }
template <class T>
struct package_name_and_function
@@ -66,12 +136,3 @@ namespace vcpkg::Commands
return nullptr;
}
}
-
-namespace vcpkg::Commands::Helpers
-{
- void print_usage();
-
- void print_example(const std::string& command_and_arguments);
-
- std::string create_example_string(const std::string& command_and_arguments);
-}
diff --git a/toolsrc/src/commands_available_commands.cpp b/toolsrc/src/commands_available_commands.cpp
index f78416aed..48239587d 100644
--- a/toolsrc/src/commands_available_commands.cpp
+++ b/toolsrc/src/commands_available_commands.cpp
@@ -5,10 +5,10 @@ namespace vcpkg::Commands
const std::vector<package_name_and_function<command_type_a>>& get_available_commands_type_a()
{
static std::vector<package_name_and_function<command_type_a>> t = {
- {"install", install_command},
- {"remove", remove_command},
- {"build", build_command},
- {"build_external", build_external_command}
+ {"install", &Install::perform_and_exit},
+ {"remove", &Remove::perform_and_exit},
+ {"build", &Build::perform_and_exit},
+ {"build_external", &BuildExternal::perform_and_exit}
};
return t;
}
@@ -16,18 +16,18 @@ namespace vcpkg::Commands
const std::vector<package_name_and_function<command_type_b>>& get_available_commands_type_b()
{
static std::vector<package_name_and_function<command_type_b>> t = {
- {"/?", help_command},
- {"help", help_command},
- {"search", search_command},
- {"list", list_command},
- {"integrate", integrate_command},
- {"owns", owns_command},
- {"update", update_command},
- {"edit", edit_command},
- {"create", create_command},
- {"import", import_command},
- {"cache", cache_command},
- {"portsdiff", portsdiff_command}
+ {"/?", &Help::perform_and_exit},
+ {"help", &Help::perform_and_exit},
+ {"search", &Search::perform_and_exit},
+ {"list", &List::perform_and_exit},
+ {"integrate", &Integrate::perform_and_exit},
+ {"owns", &Owns::perform_and_exit},
+ {"update", &Update::perform_and_exit},
+ {"edit", &Edit::perform_and_exit},
+ {"create", &Create::perform_and_exit},
+ {"import", &Import::perform_and_exit},
+ {"cache", &Cache::perform_and_exit},
+ {"portsdiff", &PortsDiff::perform_and_exit}
};
return t;
}
@@ -35,9 +35,9 @@ namespace vcpkg::Commands
const std::vector<package_name_and_function<command_type_c>>& get_available_commands_type_c()
{
static std::vector<package_name_and_function<command_type_c>> t = {
- {"version", &version_command},
- {"contact", &contact_command},
- {"hash", &hash_command},
+ {"version", &Version::perform_and_exit},
+ {"contact", &Contact::perform_and_exit},
+ {"hash", &Hash::perform_and_exit},
};
return t;
}
diff --git a/toolsrc/src/commands_build.cpp b/toolsrc/src/commands_build.cpp
index 178643d8e..72ebb264b 100644
--- a/toolsrc/src/commands_build.cpp
+++ b/toolsrc/src/commands_build.cpp
@@ -10,7 +10,7 @@
#include "vcpkg_info.h"
#include <fstream>
-namespace vcpkg::Commands
+namespace vcpkg::Commands::Build
{
using Dependencies::package_spec_with_install_plan;
using Dependencies::install_plan_type;
@@ -24,7 +24,7 @@ namespace vcpkg::Commands
std::ofstream(binary_control_file) << bpgh;
}
- void build_internal(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir)
+ void build_package(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir)
{
Checks::check_exit(spec.name() == source_paragraph.name, "inconsistent arguments to build_internal()");
const triplet& target_triplet = spec.target_triplet();
@@ -66,9 +66,9 @@ namespace vcpkg::Commands
// delete_directory(port_buildtrees_dir);
}
- void build_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
{
- static const std::string example = Helpers::create_example_string("build zlib:x64-windows");
+ static const std::string example = Commands::Help::create_example_string("build zlib:x64-windows");
// Installing multiple packages leads to unintuitive behavior if one of them depends on another.
// Allowing only 1 package for now.
@@ -122,7 +122,7 @@ namespace vcpkg::Commands
}
Environment::ensure_utilities_on_path(paths);
- Commands::build_internal(spgh, spec, paths, paths.port_dir(spec));
+ build_package(spgh, spec, paths, paths.port_dir(spec));
exit(EXIT_SUCCESS);
}
}
diff --git a/toolsrc/src/commands_build_external.cpp b/toolsrc/src/commands_build_external.cpp
index 5ed52ad97..09a9256d7 100644
--- a/toolsrc/src/commands_build_external.cpp
+++ b/toolsrc/src/commands_build_external.cpp
@@ -4,11 +4,11 @@
#include "vcpkg_Input.h"
#include "vcpkg.h"
-namespace vcpkg::Commands
+namespace vcpkg::Commands::BuildExternal
{
- void build_external_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
{
- static const std::string example = Commands::Helpers::create_example_string(R"(build_external zlib2 C:\path\to\dir\with\controlfile\)");
+ static const std::string example = Commands::Help::create_example_string(R"(build_external zlib2 C:\path\to\dir\with\controlfile\)");
args.check_exact_arg_count(2, example);
expected<package_spec> maybe_current_spec = package_spec::from_string(args.command_arguments[0], default_target_triplet);
@@ -20,13 +20,13 @@ namespace vcpkg::Commands
const expected<SourceParagraph> maybe_spgh = try_load_port(port_dir);
if (auto spgh = maybe_spgh.get())
{
- Commands::build_internal(*spgh, *spec, paths, port_dir);
+ Commands::Build::build_package(*spgh, *spec, paths, port_dir);
exit(EXIT_SUCCESS);
}
}
System::println(System::color::error, "Error: %s: %s", maybe_current_spec.error_code().message(), args.command_arguments[0]);
- Commands::Helpers::print_example(Strings::format("%s zlib:x64-windows", args.command));
+ Commands::Help::print_example(Strings::format("%s zlib:x64-windows", args.command));
exit(EXIT_FAILURE);
}
}
diff --git a/toolsrc/src/commands_cache.cpp b/toolsrc/src/commands_cache.cpp
index 3d2916418..63bf32260 100644
--- a/toolsrc/src/commands_cache.cpp
+++ b/toolsrc/src/commands_cache.cpp
@@ -4,7 +4,7 @@
#include "Paragraphs.h"
#include "BinaryParagraph.h"
-namespace vcpkg::Commands
+namespace vcpkg::Commands::Cache
{
static std::vector<BinaryParagraph> read_all_binary_paragraphs(const vcpkg_paths& paths)
{
@@ -34,10 +34,10 @@ namespace vcpkg::Commands
return output;
}
- void cache_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
{
static const std::string example = Strings::format(
- "The argument should be a substring to search for, or no argument to display all cached libraries.\n%s", Commands::Helpers::create_example_string("cache png"));
+ "The argument should be a substring to search for, or no argument to display all cached libraries.\n%s", Commands::Help::create_example_string("cache png"));
args.check_max_arg_count(1, example);
const std::vector<BinaryParagraph> binary_paragraphs = read_all_binary_paragraphs(paths);
diff --git a/toolsrc/src/commands_contact.cpp b/toolsrc/src/commands_contact.cpp
index 5bd1c1a67..3e3ebc2b4 100644
--- a/toolsrc/src/commands_contact.cpp
+++ b/toolsrc/src/commands_contact.cpp
@@ -2,9 +2,9 @@
#include "vcpkg_System.h"
#include "vcpkg_info.h"
-namespace vcpkg::Commands
+namespace vcpkg::Commands::Contact
{
- void contact_command(const vcpkg_cmd_arguments& args)
+ void perform_and_exit(const vcpkg_cmd_arguments& args)
{
args.check_exact_arg_count(0);
System::println("Send an email to %s with any feedback.", Info::email());
diff --git a/toolsrc/src/commands_create.cpp b/toolsrc/src/commands_create.cpp
index 2fcd85dba..d842d3fab 100644
--- a/toolsrc/src/commands_create.cpp
+++ b/toolsrc/src/commands_create.cpp
@@ -4,11 +4,11 @@
#include "vcpkg_Files.h"
#include "vcpkg_Input.h"
-namespace vcpkg::Commands
+namespace vcpkg::Commands::Create
{
- void create_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
{
- static const std::string example = Commands::Helpers::create_example_string(R"###(create zlib2 http://zlib.net/zlib128.zip "zlib128-2.zip")###");
+ static const std::string example = Commands::Help::create_example_string(R"###(create zlib2 http://zlib.net/zlib128.zip "zlib128-2.zip")###");
args.check_max_arg_count(3, example);
args.check_min_arg_count(2, example);
diff --git a/toolsrc/src/commands_edit.cpp b/toolsrc/src/commands_edit.cpp
index 090837a19..a4981cf80 100644
--- a/toolsrc/src/commands_edit.cpp
+++ b/toolsrc/src/commands_edit.cpp
@@ -2,11 +2,11 @@
#include "vcpkg_System.h"
#include "vcpkg_Input.h"
-namespace vcpkg::Commands
+namespace vcpkg::Commands::Edit
{
- void edit_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
{
- static const std::string example = Commands::Helpers::create_example_string("edit zlib");
+ static const std::string example = Commands::Help::create_example_string("edit zlib");
args.check_exact_arg_count(1, example);
const std::string port_name = args.command_arguments.at(0);
diff --git a/toolsrc/src/commands_hash.cpp b/toolsrc/src/commands_hash.cpp
index c6827e07a..7048fb0d9 100644
--- a/toolsrc/src/commands_hash.cpp
+++ b/toolsrc/src/commands_hash.cpp
@@ -1,7 +1,7 @@
#include "vcpkg_Commands.h"
#include "vcpkg_System.h"
-namespace vcpkg::Commands
+namespace vcpkg::Commands::Hash
{
static void do_file_hash(fs::path const& path, std::wstring const& hashType)
{
@@ -23,10 +23,10 @@ namespace vcpkg::Commands
System::println(hash);
}
- void hash_command(const vcpkg_cmd_arguments& args)
+ void perform_and_exit(const vcpkg_cmd_arguments& args)
{
static const std::string example = Strings::format(
- "The argument should be a file path\n%s", Commands::Helpers::create_example_string("hash boost_1_62_0.tar.bz2"));
+ "The argument should be a file path\n%s", Commands::Help::create_example_string("hash boost_1_62_0.tar.bz2"));
args.check_min_arg_count(1, example);
args.check_max_arg_count(2, example);
diff --git a/toolsrc/src/commands_help.cpp b/toolsrc/src/commands_help.cpp
index a0881e64d..e4769752c 100644
--- a/toolsrc/src/commands_help.cpp
+++ b/toolsrc/src/commands_help.cpp
@@ -1,37 +1,87 @@
#include "vcpkg_Commands.h"
#include "vcpkg_System.h"
-namespace vcpkg::Commands
+namespace vcpkg::Commands::Help
{
- void help_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
+ void help_topic_valid_triplet(const vcpkg_paths& paths)
+ {
+ System::println("Available architecture triplets:");
+ auto it = fs::directory_iterator(paths.triplets);
+ for (; it != fs::directory_iterator(); ++it)
+ {
+ System::println(" %s", it->path().stem().filename().string());
+ }
+ }
+
+ void print_usage()
+ {
+ System::println(
+ "Commands:\n"
+ " vcpkg search [pat] Search for packages available to be built\n"
+ " vcpkg install <pkg> Install a package\n"
+ " vcpkg remove <pkg> Uninstall a package. \n"
+ " vcpkg remove --purge <pkg> Uninstall and delete a package. \n"
+ " vcpkg list List installed packages\n"
+ " vcpkg update Display list of packages for updating\n"
+ " vcpkg hash <file> [alg] Hash a file by specific algorithm, default SHA512\n"
+ "\n"
+ "%s" // Integration help
+ "\n"
+ " vcpkg edit <pkg> Open up a port for editing (uses %%EDITOR%%, default 'code')\n"
+ " vcpkg import <pkg> Import a pre-built library\n"
+ " vcpkg create <pkg> <url>\n"
+ " [archivename] Create a new package\n"
+ " vcpkg owns <pat> Search for files in installed packages\n"
+ " vcpkg cache List cached compiled packages\n"
+ " vcpkg version Display version information\n"
+ " vcpkg contact Display contact information to send feedback\n"
+ "\n"
+ //"internal commands:\n"
+ //" --check-build-deps <controlfile>\n"
+ //" --create-binary-control <controlfile>\n"
+ //"\n"
+ "Options:\n"
+ " --triplet <t> Specify the target architecture triplet.\n"
+ " (default: %%VCPKG_DEFAULT_TRIPLET%%, see 'vcpkg help triplet')\n"
+ "\n"
+ " --vcpkg-root <path> Specify the vcpkg root directory\n"
+ " (default: %%VCPKG_ROOT%%)\n"
+ "\n"
+ "For more help (including examples) see the accompanying README.md."
+ , Integrate::INTEGRATE_COMMAND_HELPSTRING);
+ }
+
+ std::string create_example_string(const std::string& command_and_arguments)
+ {
+ std::string cs = Strings::format("Example:\n"
+ " vcpkg %s", command_and_arguments);
+ return cs;
+ }
+
+ void print_example(const std::string& command_and_arguments)
+ {
+ System::println(create_example_string(command_and_arguments));
+ }
+
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
{
args.check_max_arg_count(1);
if (args.command_arguments.empty())
{
- Commands::Helpers::print_usage();
+ print_usage();
exit(EXIT_SUCCESS);
}
const auto& topic = args.command_arguments[0];
if (topic == "triplet")
{
- Commands::help_topic_valid_triplet(paths);
+ help_topic_valid_triplet(paths);
}
else
{
System::println(System::color::error, "Error: unknown topic %s", topic);
- Commands::Helpers::print_usage();
+ print_usage();
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
}
-
- void help_topic_valid_triplet(const vcpkg_paths& paths)
- {
- System::println("Available architecture triplets:");
- auto it = fs::directory_iterator(paths.triplets);
- for (; it != fs::directory_iterator(); ++it)
- {
- System::println(" %s", it->path().stem().filename().string());
- }
- }
}
diff --git a/toolsrc/src/commands_helpers.cpp b/toolsrc/src/commands_helpers.cpp
index 5d6e519ab..0c7ce15bb 100644
--- a/toolsrc/src/commands_helpers.cpp
+++ b/toolsrc/src/commands_helpers.cpp
@@ -3,53 +3,5 @@
namespace vcpkg::Commands::Helpers
{
- void print_usage()
- {
- System::println(
- "Commands:\n"
- " vcpkg search [pat] Search for packages available to be built\n"
- " vcpkg install <pkg> Install a package\n"
- " vcpkg remove <pkg> Uninstall a package. \n"
- " vcpkg remove --purge <pkg> Uninstall and delete a package. \n"
- " vcpkg list List installed packages\n"
- " vcpkg update Display list of packages for updating\n"
- " vcpkg hash <file> [alg] Hash a file by specific algorithm, default SHA512\n"
- "\n"
- "%s" // Integration help
- "\n"
- " vcpkg edit <pkg> Open up a port for editing (uses %%EDITOR%%, default 'code')\n"
- " vcpkg import <pkg> Import a pre-built library\n"
- " vcpkg create <pkg> <url>\n"
- " [archivename] Create a new package\n"
- " vcpkg owns <pat> Search for files in installed packages\n"
- " vcpkg cache List cached compiled packages\n"
- " vcpkg version Display version information\n"
- " vcpkg contact Display contact information to send feedback\n"
- "\n"
- //"internal commands:\n"
- //" --check-build-deps <controlfile>\n"
- //" --create-binary-control <controlfile>\n"
- //"\n"
- "Options:\n"
- " --triplet <t> Specify the target architecture triplet.\n"
- " (default: %%VCPKG_DEFAULT_TRIPLET%%, see 'vcpkg help triplet')\n"
- "\n"
- " --vcpkg-root <path> Specify the vcpkg root directory\n"
- " (default: %%VCPKG_ROOT%%)\n"
- "\n"
- "For more help (including examples) see the accompanying README.md."
- , INTEGRATE_COMMAND_HELPSTRING);
- }
- std::string create_example_string(const std::string& command_and_arguments)
- {
- std::string cs = Strings::format("Example:\n"
- " vcpkg %s", command_and_arguments);
- return cs;
- }
-
- void print_example(const std::string& command_and_arguments)
- {
- System::println(create_example_string(command_and_arguments));
- }
}
diff --git a/toolsrc/src/commands_import.cpp b/toolsrc/src/commands_import.cpp
index c2c871414..14e83e75f 100644
--- a/toolsrc/src/commands_import.cpp
+++ b/toolsrc/src/commands_import.cpp
@@ -4,7 +4,7 @@
#include "vcpkg_Files.h"
#include <fstream>
-namespace vcpkg::Commands
+namespace vcpkg::Commands::Import
{
struct Binaries
{
@@ -75,9 +75,9 @@ namespace vcpkg::Commands
std::ofstream(control_file_path) << control_file_data;
}
- void import_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
{
- static const std::string example = Commands::Helpers::create_example_string(R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)");
+ static const std::string example = Commands::Help::create_example_string(R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)");
args.check_exact_arg_count(3, example);
const fs::path control_file_path(args.command_arguments[0]);
diff --git a/toolsrc/src/commands_install.cpp b/toolsrc/src/commands_install.cpp
index ff5ddb0e7..ff517d9b1 100644
--- a/toolsrc/src/commands_install.cpp
+++ b/toolsrc/src/commands_install.cpp
@@ -7,7 +7,7 @@
#include "vcpkg_Dependencies.h"
#include "vcpkg_Input.h"
-namespace vcpkg::Commands
+namespace vcpkg::Commands::Install
{
using Dependencies::package_spec_with_install_plan;
using Dependencies::install_plan_type;
@@ -183,9 +183,9 @@ namespace vcpkg::Commands
status_db.insert(std::make_unique<StatusParagraph>(spgh));
}
- void install_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
{
- static const std::string example = Commands::Helpers::create_example_string("install zlib zlib:x64-windows curl boost");
+ static const std::string example = Commands::Help::create_example_string("install zlib zlib:x64-windows curl boost");
args.check_min_arg_count(1, example);
StatusParagraphs status_db = database_load_check(paths);
@@ -216,7 +216,7 @@ namespace vcpkg::Commands
}
else if (action.plan.type == install_plan_type::BUILD_AND_INSTALL)
{
- Commands::build_internal(*action.plan.spgh, action.spec, paths, paths.port_dir(action.spec));
+ Commands::Build::build_package(*action.plan.spgh, action.spec, paths, paths.port_dir(action.spec));
const BinaryParagraph bpgh = try_load_cached_package(paths, action.spec).get_or_throw();
install_package(paths, bpgh, status_db);
System::println(System::color::success, "Package %s is installed", action.spec);
diff --git a/toolsrc/src/commands_integrate.cpp b/toolsrc/src/commands_integrate.cpp
index 323735f6d..2bd5027ec 100644
--- a/toolsrc/src/commands_integrate.cpp
+++ b/toolsrc/src/commands_integrate.cpp
@@ -10,7 +10,7 @@
#include "vcpkg_System.h"
#include "vcpkg_Files.h"
-namespace vcpkg::Commands
+namespace vcpkg::Commands::Integrate
{
static const std::array<fs::path, 2> old_system_target_files = {
"C:/Program Files (x86)/MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.nuget.targets",
@@ -293,7 +293,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console
" vcpkg integrate remove Remove user-wide integration\n"
" vcpkg integrate project Generate a referencing nuget package for individual VS project use\n";
- void integrate_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
{
static const std::string example = Strings::format("Commands:\n"
"%s", INTEGRATE_COMMAND_HELPSTRING);
diff --git a/toolsrc/src/commands_list.cpp b/toolsrc/src/commands_list.cpp
index 3e71f9c92..d9c4a52f2 100644
--- a/toolsrc/src/commands_list.cpp
+++ b/toolsrc/src/commands_list.cpp
@@ -3,7 +3,7 @@
#include "vcpkg_System.h"
#include "vcpkglib_helpers.h"
-namespace vcpkg::Commands
+namespace vcpkg::Commands::List
{
static void do_print(const StatusParagraph& pgh)
{
@@ -13,10 +13,10 @@ namespace vcpkg::Commands
details::shorten_description(pgh.package.description));
}
- void list_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
{
static const std::string example = Strings::format(
- "The argument should be a substring to search for, or no argument to display all installed libraries.\n%s", Commands::Helpers::create_example_string("list png"));
+ "The argument should be a substring to search for, or no argument to display all installed libraries.\n%s", Commands::Help::create_example_string("list png"));
args.check_max_arg_count(1, example);
const StatusParagraphs status_paragraphs = database_load_check(paths);
diff --git a/toolsrc/src/commands_owns.cpp b/toolsrc/src/commands_owns.cpp
index e7719fe68..bb1a7eb9f 100644
--- a/toolsrc/src/commands_owns.cpp
+++ b/toolsrc/src/commands_owns.cpp
@@ -2,7 +2,7 @@
#include "vcpkg_System.h"
#include "vcpkg.h"
-namespace vcpkg::Commands
+namespace vcpkg::Commands::Owns
{
static void search_file(const vcpkg_paths& paths, const std::string& file_substr, const StatusParagraphs& status_db)
{
@@ -21,9 +21,9 @@ namespace vcpkg::Commands
}
}
- void owns_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
{
- static const std::string example = Strings::format("The argument should be a pattern to search for. %s", Commands::Helpers::create_example_string("owns zlib.dll"));
+ static const std::string example = Strings::format("The argument should be a pattern to search for. %s", Commands::Help::create_example_string("owns zlib.dll"));
args.check_exact_arg_count(1, example);
StatusParagraphs status_db = database_load_check(paths);
diff --git a/toolsrc/src/commands_portsdiff.cpp b/toolsrc/src/commands_portsdiff.cpp
index 4794dee2b..1665d7c47 100644
--- a/toolsrc/src/commands_portsdiff.cpp
+++ b/toolsrc/src/commands_portsdiff.cpp
@@ -10,7 +10,7 @@
#include "SourceParagraph.h"
#include "vcpkg_Environment.h"
-namespace vcpkg::Commands
+namespace vcpkg::Commands::PortsDiff
{
static void do_print_name_and_version(const std::vector<std::string>& ports_to_print, const std::map<std::string, std::string>& names_and_versions)
{
@@ -97,9 +97,9 @@ namespace vcpkg::Commands
Checks::check_exit(output.output == VALID_COMMIT_OUTPUT, "Invalid commit id %s", Strings::utf16_to_utf8(git_commit_id));
}
- void portsdiff_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
{
- static const std::string example = Strings::format("The argument should be a branch/tag/hash to checkout.\n%s", Commands::Helpers::create_example_string("portsdiff mybranchname"));
+ static const std::string example = Strings::format("The argument should be a branch/tag/hash to checkout.\n%s", Commands::Help::create_example_string("portsdiff mybranchname"));
args.check_min_arg_count(1, example);
args.check_max_arg_count(2, example);
diff --git a/toolsrc/src/commands_remove.cpp b/toolsrc/src/commands_remove.cpp
index 16e8687e7..23d981fc1 100644
--- a/toolsrc/src/commands_remove.cpp
+++ b/toolsrc/src/commands_remove.cpp
@@ -4,7 +4,7 @@
#include "vcpkg_Input.h"
#include <fstream>
-namespace vcpkg::Commands
+namespace vcpkg::Commands::Remove
{
static const std::string OPTION_PURGE = "--purge";
@@ -166,9 +166,9 @@ namespace vcpkg::Commands
System::println(System::color::success, "Package %s was successfully removed", pkg.package.displayname());
}
- void remove_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
{
- static const std::string example = Commands::Helpers::create_example_string("remove zlib zlib:x64-windows curl boost");
+ static const std::string example = Commands::Help::create_example_string("remove zlib zlib:x64-windows curl boost");
args.check_min_arg_count(1, example);
const std::unordered_set<std::string> options = args.check_and_get_optional_command_arguments({OPTION_PURGE});
diff --git a/toolsrc/src/commands_search.cpp b/toolsrc/src/commands_search.cpp
index cc3e3fe26..3f197b06b 100644
--- a/toolsrc/src/commands_search.cpp
+++ b/toolsrc/src/commands_search.cpp
@@ -4,7 +4,7 @@
#include "vcpkglib_helpers.h"
#include "SourceParagraph.h"
-namespace vcpkg::Commands
+namespace vcpkg::Commands::Search
{
static std::vector<SourceParagraph> read_all_source_paragraphs(const vcpkg_paths& paths)
{
@@ -40,10 +40,10 @@ namespace vcpkg::Commands
details::shorten_description(source_paragraph.description));
}
- void search_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
{
static const std::string example = Strings::format("The argument should be a substring to search for, or no argument to display all libraries.\n%s",
- Commands::Helpers::create_example_string("search png"));
+ Commands::Help::create_example_string("search png"));
args.check_max_arg_count(1, example);
const std::vector<SourceParagraph> source_paragraphs = read_all_source_paragraphs(paths);
diff --git a/toolsrc/src/commands_update.cpp b/toolsrc/src/commands_update.cpp
index 9a480f3f5..12b4dad50 100644
--- a/toolsrc/src/commands_update.cpp
+++ b/toolsrc/src/commands_update.cpp
@@ -5,9 +5,9 @@
#include "Paragraphs.h"
#include "vcpkg_info.h"
-namespace vcpkg::Commands
+namespace vcpkg::Commands::Update
{
- void update_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
+ void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
{
args.check_exact_arg_count(0);
System::println("Using local portfile versions. To update the local portfiles, use `git pull`.");
diff --git a/toolsrc/src/commands_version.cpp b/toolsrc/src/commands_version.cpp
index 03cce32d4..e98251601 100644
--- a/toolsrc/src/commands_version.cpp
+++ b/toolsrc/src/commands_version.cpp
@@ -2,9 +2,9 @@
#include "vcpkg_System.h"
#include "vcpkg_info.h"
-namespace vcpkg::Commands
+namespace vcpkg::Commands::Version
{
- void version_command(const vcpkg_cmd_arguments& args)
+ void perform_and_exit(const vcpkg_cmd_arguments& args)
{
args.check_exact_arg_count(0);
System::println("Vcpkg package management program version %s\n"
diff --git a/toolsrc/src/main.cpp b/toolsrc/src/main.cpp
index 8490dc81b..08e65391f 100644
--- a/toolsrc/src/main.cpp
+++ b/toolsrc/src/main.cpp
@@ -21,7 +21,7 @@ bool g_debugging = false;
void invalid_command(const std::string& cmd)
{
System::println(System::color::error, "invalid command: %s", cmd);
- Commands::Helpers::print_usage();
+ Commands::Help::print_usage();
exit(EXIT_FAILURE);
}
@@ -30,7 +30,7 @@ static void inner(const vcpkg_cmd_arguments& args)
TrackProperty("command", args.command);
if (args.command.empty())
{
- Commands::Helpers::print_usage();
+ Commands::Help::print_usage();
exit(EXIT_FAILURE);
}
diff --git a/toolsrc/src/vcpkg_Input.cpp b/toolsrc/src/vcpkg_Input.cpp
index 0c36291b4..bf7ccd346 100644
--- a/toolsrc/src/vcpkg_Input.cpp
+++ b/toolsrc/src/vcpkg_Input.cpp
@@ -37,7 +37,7 @@ namespace vcpkg::Input
{
System::println(System::color::error, "Error: invalid triplet: %s", t.canonical_name());
TrackProperty("error", "invalid triplet: " + t.canonical_name());
- Commands::help_topic_valid_triplet(paths);
+ Commands::Help::help_topic_valid_triplet(paths);
exit(EXIT_FAILURE);
}
}
diff --git a/toolsrc/src/vcpkg_cmd_arguments.cpp b/toolsrc/src/vcpkg_cmd_arguments.cpp
index ac55e931a..aa1c35965 100644
--- a/toolsrc/src/vcpkg_cmd_arguments.cpp
+++ b/toolsrc/src/vcpkg_cmd_arguments.cpp
@@ -18,7 +18,7 @@ namespace vcpkg
{
System::println(System::color::error, "Error: expected value after %s", option_name);
TrackProperty("error", "error option name");
- Commands::Helpers::print_usage();
+ Commands::Help::print_usage();
exit(EXIT_FAILURE);
}
@@ -26,7 +26,7 @@ namespace vcpkg
{
System::println(System::color::error, "Error: %s specified multiple times", option_name);
TrackProperty("error", "error option specified multiple times");
- Commands::Helpers::print_usage();
+ Commands::Help::print_usage();
exit(EXIT_FAILURE);
}
@@ -42,7 +42,7 @@ namespace vcpkg
{
System::println(System::color::error, "Error: conflicting values specified for --%s", option_name);
TrackProperty("error", "error conflicting switches");
- Commands::Helpers::print_usage();
+ Commands::Help::print_usage();
exit(EXIT_FAILURE);
}
option_field = new_setting;
diff --git a/toolsrc/vcpkg/vcpkg.vcxproj b/toolsrc/vcpkg/vcpkg.vcxproj
index 79d348910..bcec048f5 100644
--- a/toolsrc/vcpkg/vcpkg.vcxproj
+++ b/toolsrc/vcpkg/vcpkg.vcxproj
@@ -147,7 +147,6 @@
<ClCompile Include="..\src\commands_update.cpp" />
<ClCompile Include="..\src\commands_version.cpp" />
<ClCompile Include="..\src\vcpkg_cmd_arguments.cpp" />
- <ClCompile Include="..\src\commands_helpers.cpp" />
<ClCompile Include="..\src\vcpkg_Dependencies.cpp" />
<ClCompile Include="..\src\vcpkg_Environment.cpp" />
<ClCompile Include="..\src\commands_install.cpp" />
diff --git a/toolsrc/vcpkg/vcpkg.vcxproj.filters b/toolsrc/vcpkg/vcpkg.vcxproj.filters
index 71b0635ab..1f43777b8 100644
--- a/toolsrc/vcpkg/vcpkg.vcxproj.filters
+++ b/toolsrc/vcpkg/vcpkg.vcxproj.filters
@@ -87,9 +87,6 @@
<ClCompile Include="..\src\commands_integrate.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\src\commands_helpers.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="..\src\commands_available_commands.cpp">
<Filter>Source Files</Filter>
</ClCompile>