diff options
| author | thecharlesblake | 2017-11-14 01:52:30 +0000 |
|---|---|---|
| committer | thecharlesblake | 2017-11-14 01:52:30 +0000 |
| commit | 284c1ca6b22056d008b9f91a558ce3d3e944a549 (patch) | |
| tree | a3be6183d466b2f8b2c038ce503cd27dd4bae5f6 /src/main/input-output/command_line_helper.cpp | |
| parent | Add util class, with read file to string method (diff) | |
| download | metasol-284c1ca6b22056d008b9f91a558ce3d3e944a549.tar.gz metasol-284c1ca6b22056d008b9f91a558ce3d3e944a549.zip | |
Add new valid presets logic to cmd helper
Diffstat (limited to 'src/main/input-output/command_line_helper.cpp')
| -rw-r--r-- | src/main/input-output/command_line_helper.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
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 <vector> #include <boost/program_options.hpp> +#include <input-output/sol_preset_types.h> #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<string>(); + rules_file = vm["rules"].as<string>(); } 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<string>(cerr, ", ")); - cerr << "\n"; + LOG_ERROR ("Error: Solitaire type is not valid: " << solitaire_type); print_help(); return false; } |
