From 7dc9d41aa707e5643460eeffdc1a3d52e6008358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Thu, 16 Nov 2023 15:06:45 +0100 Subject: [PATCH] pass by const& --- include/command_line_interface.h | 2 +- src/command_line_interface.cpp | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/include/command_line_interface.h b/include/command_line_interface.h index db6206c..89ce958 100644 --- a/include/command_line_interface.h +++ b/include/command_line_interface.h @@ -88,6 +88,6 @@ namespace Hanabi { /** * @brief Execute parsed parameters. */ - int run_cli(CLIParms parms); + int run_cli(CLIParms const & parms); } #endif //DYNAMIC_PROGRAM_COMMAND_LINE_INTERFACE_H diff --git a/src/command_line_interface.cpp b/src/command_line_interface.cpp index e3e3283..b748e82 100644 --- a/src/command_line_interface.cpp +++ b/src/command_line_interface.cpp @@ -32,7 +32,7 @@ namespace Hanabi { } } - int run_cli(CLIParms parms) + int run_cli(CLIParms const & parms) { // We want to do this sanity check here again, // so that the run_cli method itself can ensure that arguments are fully valid @@ -49,12 +49,6 @@ namespace Hanabi { std::ostream & quiet_os = quiet_ostream(parms.quiet); quiet_os.precision(10); - // Convert unset option to useful default, depending on some other options - if (not parms.interactive.has_value()) - { - parms.interactive = !(parms.quiet or parms.recursive); - } - // Load game, either from file or from hanab.live Game game = Download::get_game(parms.game, convert_optional(parms.score_goal)); if (not game.holds_state()) @@ -176,7 +170,7 @@ namespace Hanabi { quiet_os << "Enumerated " << game.state->position_tablebase().size() << " unique game states. " << std::endl; // If specified, we can now launch the interactive shell - if (parms.interactive) + if (parms.interactive.value_or(!parms.quiet)) { quiet_os << "\nDropping into interactive command line to explore result (type 'help'):" << std::endl; auto game_shared = std::shared_ptr(game.state.release());