From 849f3c7dd2b84d0d06c0aca07cdb2e43eb26ca53 Mon Sep 17 00:00:00 2001 From: pjht Date: Tue, 7 Nov 2023 20:42:46 -0600 Subject: [PATCH] Make state print when just running dependent on a flag --- src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index b6e4188..4960222 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,6 +65,9 @@ struct Args { /// Just run the CPU instad of starting a REPL #[clap(short, long)] run: bool, + /// If not using a REPL, print the state of the CPU on halt + #[clap(short, long, requires("run"))] + print_state: bool, } fn main() -> Result<(), anyhow::Error> { @@ -91,7 +94,9 @@ fn main() -> Result<(), anyhow::Error> { while !state.cpu.stopped { state.cpu.step(); } - println!("CPU stopped at PC {:#x}\n{}", state.cpu.pc(), state.cpu); + if args.print_state { + println!("CPU stopped at PC {:#x}\n{}", state.cpu.pc(), state.cpu); + } return Ok(()); } Repl::<_, anyhow::Error>::new(state)