better cli interface: support both files and ids
This commit is contained in:
parent
d7f7d3eb6d
commit
bfe2b85dec
1 changed files with 8 additions and 4 deletions
8
main.cpp
8
main.cpp
|
@ -14,7 +14,7 @@
|
|||
|
||||
|
||||
namespace Hanabi {
|
||||
void download(int game_id, int turn) {
|
||||
void download(std::variant<int, const char*> game_id, int turn) {
|
||||
auto game = Download::get_game(game_id, turn);
|
||||
std::cout << "Analysing state: " << std::endl << *game << std::endl;
|
||||
auto res = game->backtrack(1);
|
||||
|
@ -109,11 +109,15 @@ int main(int argc, char *argv[]) {
|
|||
#ifndef NDEBUG
|
||||
test();
|
||||
#endif
|
||||
check_games(4, 9);
|
||||
check_games(2, 9);
|
||||
if(argc == 3) {
|
||||
std::string game(argv[1]);
|
||||
std::string turn (argv[2]);
|
||||
try {
|
||||
Hanabi::download(std::stoi(game), std::stoi(turn));
|
||||
} catch(std::invalid_argument&) {
|
||||
Hanabi::download(game.c_str(), std::stoi(turn));
|
||||
}
|
||||
} else {
|
||||
Hanabi::print_usage(argv[0]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue