dynamecs_app/
cli.rs

1use crate::get_default_output_dir;
2use clap::Parser;
3use std::path::PathBuf;
4use tracing_subscriber::filter::LevelFilter;
5
6#[derive(Parser)]
7pub struct CliOptions {
8    #[arg(
9        short,
10        long,
11        help = "The path (relative or absolute) to a scenario-specific JSON5 configuration file."
12    )]
13    pub config_file: Option<PathBuf>,
14    #[arg(long, help = "A scenario configuration as a JSON5 string.")]
15    pub config_string: Option<String>,
16    #[arg(
17        short = 'o',
18        long = "output-dir",
19        help = "Output base directory, relative or absolute.",
20        default_value = get_default_output_dir().to_str().expect("will always be valid string")
21    )]
22    pub output_dir: PathBuf,
23    #[arg(long = "dt", help = "Override the time step used for the simulation.")]
24    pub dt: Option<f64>,
25    #[arg(
26        long = "max-steps",
27        help = "Maximum number of simulation steps to take (by default infinite)"
28    )]
29    pub max_steps: Option<usize>,
30    #[arg(
31        long = "write-checkpoints",
32        help = "Write a checkpoint file to disk after every timestep"
33    )]
34    pub write_checkpoints: bool,
35    #[arg(
36        long = "restore-checkpoint",
37        help = "Restore the simulation state from a checkpoint file and continue the simulation"
38    )]
39    pub restore_checkpoint: Option<PathBuf>,
40    #[arg(
41        long,
42        default_value = "info",
43        help = "Log level to use for logging to the console. \
44                Possible values: off, error, warn, info, debug, trace."
45    )]
46    pub console_log_level: LevelFilter,
47    #[arg(
48        long,
49        default_value = "debug",
50        help = "Log level to use for text and JSON log files. \
51                Possible values: off, error, warn, info, debug, trace."
52    )]
53    pub file_log_level: LevelFilter,
54    #[arg(
55        long = "override",
56        help = "Override a configuration option using the syntax <path.in.json>=<new value>. \
57        Multiple overrides are applied in sequence."
58    )]
59    pub overrides: Vec<String>,
60    #[arg(long = "compress-logs", help = "Compress logs with gzip compression.")]
61    pub compress_logs: bool,
62    #[arg(long = "no-archive", help = "Disable timestamped archive logs.", action = clap::ArgAction::SetFalse)]
63    pub archive_logs: bool,
64    #[arg(
65        long = "allow-unknown-config",
66        help = "Allow unknown fields in scenario configuration. This is disabled by default in order to prevent ignoring misspelled keys or similar mistakes."
67    )]
68    pub allow_unknown_config: bool,
69}