diff --git a/src/args.rs b/src/args.rs index 74bea13..5361019 100644 --- a/src/args.rs +++ b/src/args.rs @@ -14,7 +14,7 @@ // along with this program. If not, see . use crate::types::Variant; -use clap::Parser; +use clap::{ArgAction, Parser}; use std::default::Default; #[derive(Parser, Debug)] @@ -27,4 +27,8 @@ pub struct Args { /// Game variant. Unused #[clap(arg_enum, short, long, default_value_t = Default::default())] pub variant: Variant, + + /// Recording + #[clap(name = "no-recording", long, action = ArgAction::SetFalse, default_value_t = true)] + pub recording: bool, } diff --git a/src/main.rs b/src/main.rs index 34f2bc0..549004e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -71,10 +71,12 @@ fn main() -> Result<(), Error> { args.players, dt.format("%Y-%m-%d_%H:%M:%S") ); - println!("Recording at: {}", filename); + if args.recording { + println!("Recording at: {}", filename); - // TODO: Move writing to GameState - write_header(filename.clone().as_str(), args.players, vec![args.variant])?; + // TODO: Move writing to GameState + write_header(filename.clone().as_str(), args.players, vec![args.variant])?; + } let mut rl = Editor::<()>::new()?; let mut game: GameState = GameState::new(args.players, vec![args.variant]); @@ -89,7 +91,9 @@ fn main() -> Result<(), Error> { Action::Game(action) => { game.add_action(action.clone()); // TODO: Move writing to GameState - write_actions(filename.clone().as_str(), action)? + if args.recording { + write_actions(filename.clone().as_str(), action)? + } } Action::Repl(ReplAction::DisplayBoard) => game.show(), _ => (),