From 284c1ca6b22056d008b9f91a558ce3d3e944a549 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Tue, 14 Nov 2017 01:52:30 +0000 Subject: Add new valid presets logic to cmd helper --- src/main/input-output/command_line_helper.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/main/input-output/command_line_helper.cpp') diff --git a/src/main/input-output/command_line_helper.cpp b/src/main/input-output/command_line_helper.cpp index 37908a2..49bb300 100644 --- a/src/main/input-output/command_line_helper.cpp +++ b/src/main/input-output/command_line_helper.cpp @@ -6,6 +6,7 @@ #include #include +#include #include "command_line_helper.h" #include "game/sol_rules.h" @@ -68,7 +69,7 @@ bool command_line_helper::parse(int argc, const char* argv[]) { } if (vm.count("rules")) { - rules_file = vm["type"].as(); + rules_file = vm["rules"].as(); } if (vm.count("random")) { @@ -100,8 +101,8 @@ bool command_line_helper::assess_errors() { } // The user must supply either a solitaire type or a rules file - if (solitaire_type.empty() && rules_file.empty() - || !solitaire_type.empty() && !rules_file.empty()) { + if ((solitaire_type.empty() && rules_file.empty()) + || (!solitaire_type.empty() && !rules_file.empty())) { print_sol_type_rules_error(); return false; } @@ -115,17 +116,11 @@ bool command_line_helper::assess_errors() { // Checks if the supplied solitaire type is in the list of valid solitaires bool command_line_helper::assess_sol_type() { - if (find(sol_rules::valid_sol_strs.begin(), - sol_rules::valid_sol_strs.end(), - solitaire_type) != sol_rules::valid_sol_strs.end()) { + if (sol_preset_types::is_valid_preset(solitaire_type)) { return true; } else { - LOG_ERROR ("Error: Solitaire type is not valid: " << solitaire_type - << "\nValid solitaire types are: "); - copy(begin(sol_rules::valid_sol_strs), end(sol_rules::valid_sol_strs), - ostream_iterator(cerr, ", ")); - cerr << "\n"; + LOG_ERROR ("Error: Solitaire type is not valid: " << solitaire_type); print_help(); return false; } -- cgit v1.2.1