Make state print when just running dependent on a flag

This commit is contained in:
pjht 2023-11-07 20:42:46 -06:00
parent ec14039a40
commit 849f3c7dd2
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

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