diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-01-12 17:35:33 -0800 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-01-12 17:43:05 -0800 |
| commit | df2a05e8546281135c6ea12430734d74371bcf46 (patch) | |
| tree | f64c97d48fbcb506def9b089cc4311736dcf08de /toolsrc/src | |
| parent | 4c51e65d5004311c7c7ba0687e7dba934ba986c1 (diff) | |
| download | vcpkg-df2a05e8546281135c6ea12430734d74371bcf46.tar.gz vcpkg-df2a05e8546281135c6ea12430734d74371bcf46.zip | |
Introduce Command namespace. Refactoring
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/commands_available_commands.cpp | 44 | ||||
| -rw-r--r-- | toolsrc/src/commands_build.cpp | 80 | ||||
| -rw-r--r-- | toolsrc/src/commands_build_external.cpp | 8 | ||||
| -rw-r--r-- | toolsrc/src/commands_cache.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/commands_create.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/commands_edit.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/commands_hash.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/commands_help.cpp | 8 | ||||
| -rw-r--r-- | toolsrc/src/commands_helpers.cpp (renamed from toolsrc/src/commands_other.cpp) | 50 | ||||
| -rw-r--r-- | toolsrc/src/commands_import.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/commands_install.cpp | 6 | ||||
| -rw-r--r-- | toolsrc/src/commands_integrate.cpp | 2 | ||||
| -rw-r--r-- | toolsrc/src/commands_list.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/commands_owns.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/commands_portsdiff.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/commands_remove.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/commands_search.cpp | 5 | ||||
| -rw-r--r-- | toolsrc/src/commands_update.cpp | 2 | ||||
| -rw-r--r-- | toolsrc/src/main.cpp | 10 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Input.cpp | 2 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_cmd_arguments.cpp | 6 |
21 files changed, 127 insertions, 132 deletions
diff --git a/toolsrc/src/commands_available_commands.cpp b/toolsrc/src/commands_available_commands.cpp new file mode 100644 index 000000000..f78416aed --- /dev/null +++ b/toolsrc/src/commands_available_commands.cpp @@ -0,0 +1,44 @@ +#include "vcpkg_Commands.h" + +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} + }; + return t; + } + + 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} + }; + return t; + } + + 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}, + }; + return t; + } +} diff --git a/toolsrc/src/commands_build.cpp b/toolsrc/src/commands_build.cpp index 9f37e25f9..178643d8e 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 +namespace vcpkg::Commands { using Dependencies::package_spec_with_install_plan; using Dependencies::install_plan_type; @@ -24,53 +24,51 @@ namespace vcpkg std::ofstream(binary_control_file) << bpgh; } - namespace Commands::details + void build_internal(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir) { - void build_internal(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(); + + const fs::path ports_cmake_script_path = paths.ports_cmake; + const std::wstring command = Strings::wformat(LR"("%%VS140COMNTOOLS%%..\..\VC\vcvarsall.bat" %s && cmake -DCMD=BUILD -DPORT=%s -DTARGET_TRIPLET=%s "-DCURRENT_PORT_DIR=%s/." -P "%s")", + Strings::utf8_to_utf16(target_triplet.architecture()), + Strings::utf8_to_utf16(source_paragraph.name), + Strings::utf8_to_utf16(target_triplet.canonical_name()), + port_dir.generic_wstring(), + ports_cmake_script_path.generic_wstring()); + + System::Stopwatch2 timer; + timer.start(); + int return_code = System::cmd_execute(command); + timer.stop(); + TrackMetric("buildtimeus-" + to_string(spec), timer.microseconds()); + + if (return_code != 0) { - Checks::check_exit(spec.name() == source_paragraph.name, "inconsistent arguments to build_internal()"); - const triplet& target_triplet = spec.target_triplet(); - - const fs::path ports_cmake_script_path = paths.ports_cmake; - const std::wstring command = Strings::wformat(LR"("%%VS140COMNTOOLS%%..\..\VC\vcvarsall.bat" %s && cmake -DCMD=BUILD -DPORT=%s -DTARGET_TRIPLET=%s "-DCURRENT_PORT_DIR=%s/." -P "%s")", - Strings::utf8_to_utf16(target_triplet.architecture()), - Strings::utf8_to_utf16(source_paragraph.name), - Strings::utf8_to_utf16(target_triplet.canonical_name()), - port_dir.generic_wstring(), - ports_cmake_script_path.generic_wstring()); - - System::Stopwatch2 timer; - timer.start(); - int return_code = System::cmd_execute(command); - timer.stop(); - TrackMetric("buildtimeus-" + to_string(spec), timer.microseconds()); - - if (return_code != 0) - { - System::println(System::color::error, "Error: building package %s failed", to_string(spec)); - System::println("Please ensure sure you're using the latest portfiles with `vcpkg update`, then\n" - "submit an issue at https://github.com/Microsoft/vcpkg/issues including:\n" - " Package: %s\n" - " Vcpkg version: %s\n" - "\n" - "Additionally, attach any relevant sections from the log files above." - , to_string(spec), Info::version()); - TrackProperty("error", "build failed"); - TrackProperty("build_error", to_string(spec)); - exit(EXIT_FAILURE); - } + System::println(System::color::error, "Error: building package %s failed", to_string(spec)); + System::println("Please ensure sure you're using the latest portfiles with `vcpkg update`, then\n" + "submit an issue at https://github.com/Microsoft/vcpkg/issues including:\n" + " Package: %s\n" + " Vcpkg version: %s\n" + "\n" + "Additionally, attach any relevant sections from the log files above." + , to_string(spec), Info::version()); + TrackProperty("error", "build failed"); + TrackProperty("build_error", to_string(spec)); + exit(EXIT_FAILURE); + } - PostBuildLint::perform_all_checks(spec, paths); + PostBuildLint::perform_all_checks(spec, paths); - create_binary_control_file(paths, source_paragraph, target_triplet); + create_binary_control_file(paths, source_paragraph, target_triplet); - // const fs::path port_buildtrees_dir = paths.buildtrees / spec.name; - // delete_directory(port_buildtrees_dir); - } + // const fs::path port_buildtrees_dir = paths.buildtrees / spec.name; + // delete_directory(port_buildtrees_dir); } + void build_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet) { - static const std::string example = create_example_string("build zlib:x64-windows"); + static const std::string example = Helpers::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. @@ -124,7 +122,7 @@ namespace vcpkg } Environment::ensure_utilities_on_path(paths); - Commands::details::build_internal(spgh, spec, paths, paths.port_dir(spec)); + Commands::build_internal(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 d34981e04..5ed52ad97 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 +namespace vcpkg::Commands { void build_external_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet) { - static const std::string example = create_example_string(R"(build_external zlib2 C:\path\to\dir\with\controlfile\)"); + static const std::string example = Commands::Helpers::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 const expected<SourceParagraph> maybe_spgh = try_load_port(port_dir); if (auto spgh = maybe_spgh.get()) { - Commands::details::build_internal(*spgh, *spec, paths, port_dir); + Commands::build_internal(*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]); - print_example(Strings::format("%s zlib:x64-windows", args.command)); + Commands::Helpers::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 1a10b93cf..3d2916418 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 +namespace vcpkg::Commands { static std::vector<BinaryParagraph> read_all_binary_paragraphs(const vcpkg_paths& paths) { @@ -37,7 +37,7 @@ namespace vcpkg void cache_command(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", 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::Helpers::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_create.cpp b/toolsrc/src/commands_create.cpp index ad00cd676..2fcd85dba 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 +namespace vcpkg::Commands { void create_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) { - static const std::string example = create_example_string(R"###(create zlib2 http://zlib.net/zlib128.zip "zlib128-2.zip")###"); + static const std::string example = Commands::Helpers::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 f7c489f2b..090837a19 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 +namespace vcpkg::Commands { void edit_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) { - static const std::string example = create_example_string("edit zlib"); + static const std::string example = Commands::Helpers::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 0e3e8a77c..c6827e07a 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 +namespace vcpkg::Commands { static void do_file_hash(fs::path const& path, std::wstring const& hashType) { @@ -26,7 +26,7 @@ namespace vcpkg void hash_command(const vcpkg_cmd_arguments& args) { static const std::string example = Strings::format( - "The argument should be a file path\n%s", create_example_string("hash boost_1_62_0.tar.bz2")); + "The argument should be a file path\n%s", Commands::Helpers::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 fd02d948e..5baec62c7 100644 --- a/toolsrc/src/commands_help.cpp +++ b/toolsrc/src/commands_help.cpp @@ -2,7 +2,7 @@ #include "vcpkg_System.h" #include "vcpkg_info.h" -namespace vcpkg +namespace vcpkg::Commands { void version_command(const vcpkg_cmd_arguments& args) { @@ -19,18 +19,18 @@ namespace vcpkg args.check_max_arg_count(1); if (args.command_arguments.empty()) { - print_usage(); + Commands::Helpers::print_usage(); exit(EXIT_SUCCESS); } const auto& topic = args.command_arguments[0]; if (topic == "triplet") { - help_topic_valid_triplet(paths); + Commands::help_topic_valid_triplet(paths); } else { System::println(System::color::error, "Error: unknown topic %s", topic); - print_usage(); + Commands::Helpers::print_usage(); exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); diff --git a/toolsrc/src/commands_other.cpp b/toolsrc/src/commands_helpers.cpp index 6df325100..5d6e519ab 100644 --- a/toolsrc/src/commands_other.cpp +++ b/toolsrc/src/commands_helpers.cpp @@ -1,7 +1,7 @@ #include "vcpkg_Commands.h" #include "vcpkg_System.h" -namespace vcpkg +namespace vcpkg::Commands::Helpers { void print_usage() { @@ -52,52 +52,4 @@ namespace vcpkg { System::println(create_example_string(command_and_arguments)); } - - void internal_test_command(const vcpkg_cmd_arguments& /*args*/, const vcpkg_paths& /*paths*/) - { - // auto data = FormatEventData("test"); - // Track(data); - exit(EXIT_SUCCESS); - } - - 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} - }; - return t; - } - - 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}, - {"internal_test", internal_test_command}, - {"portsdiff", portsdiff_command} - }; - return t; - } - - 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}, - }; - return t; - } } diff --git a/toolsrc/src/commands_import.cpp b/toolsrc/src/commands_import.cpp index 3832f0e7b..c2c871414 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 +namespace vcpkg::Commands { struct Binaries { @@ -77,7 +77,7 @@ namespace vcpkg void import_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) { - static const std::string example = create_example_string(R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)"); + static const std::string example = Commands::Helpers::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 f44852930..ff5ddb0e7 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 +namespace vcpkg::Commands { using Dependencies::package_spec_with_install_plan; using Dependencies::install_plan_type; @@ -185,7 +185,7 @@ namespace vcpkg void install_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet) { - static const std::string example = create_example_string("install zlib zlib:x64-windows curl boost"); + static const std::string example = Commands::Helpers::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 } else if (action.plan.type == install_plan_type::BUILD_AND_INSTALL) { - Commands::details::build_internal(*action.plan.spgh, action.spec, paths, paths.port_dir(action.spec)); + Commands::build_internal(*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 e7e5b2d8d..323735f6d 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 +namespace vcpkg::Commands { 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", diff --git a/toolsrc/src/commands_list.cpp b/toolsrc/src/commands_list.cpp index cc51232e9..3e71f9c92 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 +namespace vcpkg::Commands { static void do_print(const StatusParagraph& pgh) { @@ -16,7 +16,7 @@ namespace vcpkg void list_command(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", 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::Helpers::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 62dac57eb..e7719fe68 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 +namespace vcpkg::Commands { static void search_file(const vcpkg_paths& paths, const std::string& file_substr, const StatusParagraphs& status_db) { @@ -23,7 +23,7 @@ namespace vcpkg void owns_command(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", create_example_string("owns zlib.dll")); + 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")); 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 46c6c90c7..4794dee2b 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 +namespace vcpkg::Commands { 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) { @@ -99,7 +99,7 @@ namespace vcpkg void portsdiff_command(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", 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::Helpers::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 445213fc2..16e8687e7 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 +namespace vcpkg::Commands { static const std::string OPTION_PURGE = "--purge"; @@ -168,7 +168,7 @@ namespace vcpkg void remove_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet) { - static const std::string example = create_example_string("remove zlib zlib:x64-windows curl boost"); + static const std::string example = Commands::Helpers::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 a4714477e..cc3e3fe26 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 +namespace vcpkg::Commands { static std::vector<SourceParagraph> read_all_source_paragraphs(const vcpkg_paths& paths) { @@ -42,7 +42,8 @@ namespace vcpkg void search_command(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", create_example_string("search png")); + 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")); 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 a4ab7c6e7..9a480f3f5 100644 --- a/toolsrc/src/commands_update.cpp +++ b/toolsrc/src/commands_update.cpp @@ -5,7 +5,7 @@ #include "Paragraphs.h" #include "vcpkg_info.h" -namespace vcpkg +namespace vcpkg::Commands { void update_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) { diff --git a/toolsrc/src/main.cpp b/toolsrc/src/main.cpp index 7703c541f..8490dc81b 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); - print_usage(); + Commands::Helpers::print_usage(); exit(EXIT_FAILURE); } @@ -30,11 +30,11 @@ static void inner(const vcpkg_cmd_arguments& args) TrackProperty("command", args.command); if (args.command.empty()) { - print_usage(); + Commands::Helpers::print_usage(); exit(EXIT_FAILURE); } - if (auto command_function = find_command(args.command, get_available_commands_type_c())) + if (auto command_function = Commands::find(args.command, Commands::get_available_commands_type_c())) { return command_function(args); } @@ -66,7 +66,7 @@ static void inner(const vcpkg_cmd_arguments& args) int exit_code = _wchdir(paths.root.c_str()); Checks::check_exit(exit_code == 0, "Changing the working dir failed"); - if (auto command_function = find_command(args.command, get_available_commands_type_b())) + if (auto command_function = Commands::find(args.command, Commands::get_available_commands_type_b())) { return command_function(args, paths); } @@ -91,7 +91,7 @@ static void inner(const vcpkg_cmd_arguments& args) Input::check_triplet(default_target_triplet, paths); - if (auto command_function = find_command(args.command, get_available_commands_type_a())) + if (auto command_function = Commands::find(args.command, Commands::get_available_commands_type_a())) { return command_function(args, paths, default_target_triplet); } diff --git a/toolsrc/src/vcpkg_Input.cpp b/toolsrc/src/vcpkg_Input.cpp index 365f28cdb..0c36291b4 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()); - help_topic_valid_triplet(paths); + Commands::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 a3648668f..ac55e931a 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"); - print_usage(); + Commands::Helpers::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"); - print_usage(); + Commands::Helpers::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"); - print_usage(); + Commands::Helpers::print_usage(); exit(EXIT_FAILURE); } option_field = new_setting; |
