From fc1e55173b23afeb46142e6d656043a4b6f4b21c Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Fri, 30 Sep 2016 11:24:04 -0700 Subject: Rename check_max_args to check_max_arg_count and introduce min/exact variants --- toolsrc/src/commands_installation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toolsrc/src/commands_installation.cpp') diff --git a/toolsrc/src/commands_installation.cpp b/toolsrc/src/commands_installation.cpp index 2890184fb..6604685c0 100644 --- a/toolsrc/src/commands_installation.cpp +++ b/toolsrc/src/commands_installation.cpp @@ -122,7 +122,7 @@ namespace vcpkg { // Installing multiple packages leads to unintuitive behavior if one of them depends on another. // Allowing only 1 package for now. - args.check_max_args(1); + args.check_max_arg_count(1); StatusParagraphs status_db = database_load_check(paths); -- cgit v1.2.3 From b2c1076aef280e7ebfd38845dfcb4d4b66cd45e3 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Fri, 30 Sep 2016 11:24:04 -0700 Subject: All commands now use the new functions for argument checking --- toolsrc/src/commands_installation.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'toolsrc/src/commands_installation.cpp') diff --git a/toolsrc/src/commands_installation.cpp b/toolsrc/src/commands_installation.cpp index 6604685c0..baa0e6951 100644 --- a/toolsrc/src/commands_installation.cpp +++ b/toolsrc/src/commands_installation.cpp @@ -65,6 +65,8 @@ 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"); + args.check_min_arg_count(1, example.c_str()); StatusParagraphs status_db = database_load_check(paths); std::vector specs = args.parse_all_arguments_as_package_specs(default_target_triplet); @@ -120,10 +122,12 @@ namespace vcpkg 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"); + // Installing multiple packages leads to unintuitive behavior if one of them depends on another. - // Allowing only 1 package for now. - args.check_max_arg_count(1); + // Allowing only 1 package for now. + args.check_exact_arg_count(1, example.c_str()); StatusParagraphs status_db = database_load_check(paths); const package_spec spec = args.parse_all_arguments_as_package_specs(default_target_triplet).at(0); @@ -148,12 +152,8 @@ namespace vcpkg void build_external_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet) { - if (args.command_arguments.size() != 2) - { - System::println(System::color::error, "Error: buildexternal requires the package name and the directory containing the CONTROL file"); - print_example(R"(buildexternal mylib C:\path\to\mylib\)"); - exit(EXIT_FAILURE); - } + static const std::string example = create_example_string(R"(build_external zlib2 C:\path\to\dir\with\controlfile\)"); + args.check_exact_arg_count(2, example.c_str()); expected current_spec = package_spec::from_string(args.command_arguments[0], default_target_triplet); if (auto spec = current_spec.get()) -- cgit v1.2.3 From d7c357db2e3b6c15c422f5b631dcb089c245d3bf Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Fri, 30 Sep 2016 16:38:29 -0700 Subject: Replace usage of parse_all_args_as_package_specs with the new functions --- toolsrc/src/commands_installation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toolsrc/src/commands_installation.cpp') diff --git a/toolsrc/src/commands_installation.cpp b/toolsrc/src/commands_installation.cpp index baa0e6951..9eacfedcc 100644 --- a/toolsrc/src/commands_installation.cpp +++ b/toolsrc/src/commands_installation.cpp @@ -69,7 +69,7 @@ namespace vcpkg args.check_min_arg_count(1, example.c_str()); StatusParagraphs status_db = database_load_check(paths); - std::vector specs = args.parse_all_arguments_as_package_specs(default_target_triplet); + std::vector specs = vcpkg_cmd_arguments::check_and_get_package_specs(args.command_arguments, default_target_triplet, example.c_str()); std::vector install_plan = Dependencies::create_dependency_ordered_install_plan(paths, specs, status_db); Checks::check_exit(!install_plan.empty(), "Install plan cannot be empty"); std::string specs_string = to_string(install_plan[0]); @@ -130,7 +130,7 @@ namespace vcpkg args.check_exact_arg_count(1, example.c_str()); StatusParagraphs status_db = database_load_check(paths); - const package_spec spec = args.parse_all_arguments_as_package_specs(default_target_triplet).at(0); + const package_spec spec = vcpkg_cmd_arguments::check_and_get_package_spec(args.command_arguments.at(0), default_target_triplet, example.c_str()); std::unordered_set unmet_dependencies = Dependencies::find_unmet_dependencies(paths, spec, status_db); if (!unmet_dependencies.empty()) { -- cgit v1.2.3