mahjong_cli/simulate/
simulate_cli.rs1use clap::{Arg, ArgAction, Command};
2
3#[derive(Debug, Clone, PartialEq)]
4pub struct SimulateOpts {
5 pub once: bool,
6 pub debug: bool,
7}
8
9pub fn get_simulate_command() -> Command {
10 Command::new("simulate")
11 .about("Simulates games")
12 .arg(
13 Arg::new("once")
14 .short('o')
15 .help("Only run one simulation")
16 .action(ArgAction::SetTrue),
17 )
18 .arg(
19 Arg::new("debug")
20 .short('d')
21 .help("Store debugging information to troubleshoot issues")
22 .action(ArgAction::SetTrue),
23 )
24}
25
26pub fn get_simulate_opts(matches: &clap::ArgMatches) -> SimulateOpts {
27 let once: Option<&bool> = matches.get_one("once");
28 let debug: Option<&bool> = matches.get_one("debug");
29
30 SimulateOpts {
31 once: once == Some(&true),
32 debug: debug == Some(&true),
33 }
34}