diff options
| author | Charlie Blake | 2018-04-05 15:54:20 +0100 |
|---|---|---|
| committer | GitHub | 2018-04-05 15:54:20 +0100 |
| commit | 4c4bf8a2e153b0ead77931285704aa7a0d2b7475 (patch) | |
| tree | 716b8cc644945daaa1d9665f7ffc98a25d4a36d4 /src/main/input-output/input/command_line_helper.cpp | |
| parent | Merge pull request #48 from thecharlesblake/wider-testing (diff) | |
| parent | Add cmd line opts to list games and describe rules (diff) | |
| download | metasol-4c4bf8a2e153b0ead77931285704aa7a0d2b7475.tar.gz metasol-4c4bf8a2e153b0ead77931285704aa7a0d2b7475.zip | |
Merge pull request #49 from thecharlesblake/add-more-games
Add more games
Diffstat (limited to 'src/main/input-output/input/command_line_helper.cpp')
| -rw-r--r-- | src/main/input-output/input/command_line_helper.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/main/input-output/input/command_line_helper.cpp b/src/main/input-output/input/command_line_helper.cpp index 7853b55..5518f1f 100644 --- a/src/main/input-output/input/command_line_helper.cpp +++ b/src/main/input-output/input/command_line_helper.cpp @@ -22,11 +22,17 @@ command_line_helper::command_line_helper() main_options.add_options() ("help", "produce help message") ("type", po::value<string>(), - "specify the type of the solitaire game to be solved. Must supply " - "either 'type' or 'rules' file") - ("rules", po::value<string>(), + "specify the type of the solitaire game to be solved from the list " + "of preset games. Must supply either this 'type' option, " + "or the 'custom-rules' option") + ("available-game-types", "outputs a list of the different preset " + "game types that can be solved") + ("describe-game-rules", po::value<string>(), + "outputs the JSON that describes the rules of the supplied " + "preset game type") + ("custom-rules", po::value<string>(), "the path to a JSON file describing the rules of the solitaire " - "to be solved. Must supply either 'type' or 'rules' file") + "to be solved. Must supply either 'type' or 'custom-rules' option") ("random", po::value<int>(), "create and solve a random solitaire " "deal based on a seed. Must supply either 'random'," "'solvability' or list of deals to be solved.") @@ -68,6 +74,12 @@ bool command_line_helper::parse(int argc, const char* argv[]) { help = (vm.count("help") != 0); + available_game_types = (vm.count("available-game-types") != 0); + + if (vm.count("describe-game-rules")) { + describe_game_rules = vm["describe-game-rules"].as<string>(); + } + classify = (vm.count("classify") != 0); if (vm.count("input-files")) { @@ -102,6 +114,8 @@ bool command_line_helper::assess_errors() { return false; } + if (available_game_types || !describe_game_rules.empty()) return true; + // The user must either supply input files, a random seed, or ask for the // solvability percentage int opt_count = (random_deal != -1) + !input_files.empty() + solvability; @@ -146,8 +160,8 @@ bool command_line_helper::assess_sol_type() { } void command_line_helper::print_help() { - LOG_ERROR ("Usage: solvitaire [options] input-file1 input-file2 ...\n" - << main_options); + cerr << "Usage: solvitaire [options] input-file1 input-file2 ...\n" + << main_options << "\n"; } void command_line_helper::print_no_opts_error() { @@ -201,6 +215,14 @@ bool command_line_helper::get_solvability() { return solvability; } +bool command_line_helper::get_available_game_types() { + return available_game_types; +} + +string command_line_helper::get_describe_game_rules() { + return describe_game_rules; +} + bool command_line_helper::get_short_sols() { return shortest_sols; } |
