@@ -36,6 +36,9 @@ pub enum Commands {
3636 /// Directory for output files
3737 #[ arg( short, long) ]
3838 output_dir : Option < PathBuf > ,
39+ /// Whether to write additional information to CSV files
40+ #[ arg( long) ]
41+ debug_model : bool ,
3942 } ,
4043 /// Manage example models.
4144 Example {
@@ -64,13 +67,25 @@ pub enum ExampleSubcommands {
6467 /// Directory for output files
6568 #[ arg( short, long) ]
6669 output_dir : Option < PathBuf > ,
70+ /// Whether to write additional information to CSV files
71+ #[ arg( long) ]
72+ debug_model : bool ,
6773 } ,
6874}
6975
7076/// Handle the `run` command.
71- pub fn handle_run_command ( model_path : & Path , output_path : Option < & Path > ) -> Result < ( ) > {
77+ pub fn handle_run_command (
78+ model_path : & Path ,
79+ output_path : Option < & Path > ,
80+ debug_model : bool ,
81+ ) -> Result < ( ) > {
7282 // Load program settings
73- let settings = Settings :: from_path ( model_path) . context ( "Failed to load settings." ) ?;
83+ let mut settings = Settings :: from_path ( model_path) . context ( "Failed to load settings." ) ?;
84+
85+ // This setting can be overridden by command-line argument
86+ if debug_model {
87+ settings. debug_model = true ;
88+ }
7489
7590 // Create output folder
7691 let output_path = match output_path {
@@ -90,7 +105,7 @@ pub fn handle_run_command(model_path: &Path, output_path: Option<&Path>) -> Resu
90105 info ! ( "Output data will be written to {}" , output_path. display( ) ) ;
91106
92107 // Run the simulation
93- crate :: simulation:: run ( model, assets, & output_path)
108+ crate :: simulation:: run ( model, assets, & output_path, settings . debug_model )
94109 } ;
95110
96111 // Once the logger is initialised, we can write fatal errors to log
@@ -142,9 +157,13 @@ fn extract_example(name: &str, new_path: &Path) -> Result<()> {
142157}
143158
144159/// Handle the `example run` command.
145- pub fn handle_example_run_command ( name : & str , output_path : Option < & Path > ) -> Result < ( ) > {
160+ pub fn handle_example_run_command (
161+ name : & str ,
162+ output_path : Option < & Path > ,
163+ debug_model : bool ,
164+ ) -> Result < ( ) > {
146165 let temp_dir = TempDir :: new ( ) . context ( "Failed to create temporary directory." ) ?;
147166 let model_path = temp_dir. path ( ) . join ( name) ;
148167 extract_example ( name, & model_path) ?;
149- handle_run_command ( & model_path, output_path)
168+ handle_run_command ( & model_path, output_path, debug_model )
150169}
0 commit comments