pass by const&

This commit is contained in:
Maximilian Keßler 2023-11-16 15:06:45 +01:00
parent f0257a1292
commit 7dc9d41aa7
Signed by: max
GPG Key ID: BCC5A619923C0BA5
2 changed files with 3 additions and 9 deletions

View File

@ -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

View File

@ -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<HanabiStateIF>(game.state.release());