args: --no-recording argument

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2022-08-20 11:30:00 +02:00
parent 553abf5abe
commit fe40316b2c
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2
2 changed files with 13 additions and 5 deletions

View file

@ -14,7 +14,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
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,
}

View file

@ -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(),
_ => (),