diff options
Diffstat (limited to 'src/main/command_line_helper.cpp')
| -rw-r--r-- | src/main/command_line_helper.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/main/command_line_helper.cpp b/src/main/command_line_helper.cpp index fdf6c9c..22678af 100644 --- a/src/main/command_line_helper.cpp +++ b/src/main/command_line_helper.cpp @@ -14,6 +14,9 @@ using namespace std; namespace po = boost::program_options; +vector<string> command_line_helper::valid_sol_types = + {"black-hole", "simple-black-hole", "spanish-patience"}; + command_line_helper::command_line_helper() : main_options("options"), random_deal(-1) { @@ -78,12 +81,12 @@ bool command_line_helper::assess_errors() { bool valid_sol_type = assess_sol_type(); if (!valid_sol_type) return false; - if (random_deal >= 0 && !input_files.empty()) { + if (random_deal != -1 && !input_files.empty()) { print_rand_plus_input_err(); return false; } - if (input_files.empty() && random_deal >= 0) { + if (input_files.empty() && random_deal == -1) { print_no_input_error(); return false; } @@ -91,21 +94,22 @@ bool command_line_helper::assess_errors() { } bool command_line_helper::assess_sol_type() { - if (solitaire_type == "black-hole") { - return true; - } else if (solitaire_type == "simple-black-hole") { + if (find(valid_sol_types.begin(), valid_sol_types.end(), solitaire_type) != + valid_sol_types.end()) { return true; } else { cerr << "Error: Solitaire type is not valid: " << solitaire_type - << "\nValid solitaire types are: 'black-hole' and " - "'simple-black-hole'"; + << "\nValid solitaire types are: "; + copy(begin(valid_sol_types), end(valid_sol_types), + ostream_iterator<string>(cerr, ", ")); + cerr << "\n"; print_help(); return false; } } void command_line_helper::print_help() { - cout << "Usage: solvitaire [options] input-file1 input-file2 ...\n" + cerr << "Usage: solvitaire [options] input-file1 input-file2 ...\n" << main_options << "\n"; } |
