diff --git a/INSTALL.md b/INSTALL.md index e043071..0010aae 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -42,14 +42,17 @@ The application will now be invokable from your terminal as `topola`. #### Autorouting example -As an example, running the following commands will autoroute a KiCad project of a -simple THT diode bridge rectifier: +As an example, running the following commands will autoroute a KiCad +project of a simple THT diode bridge rectifier: ``` cd tests/single_layer/data/tht_diode_bridge_rectifier/ -topola tht_diode_bridge_rectifier.dsn tht_diode_bridge_rectifier.ses +topola tht_diode_bridge_rectifier.dsn ``` +By default, the output filename is the input filename with extension +changed to `ses`: `tht_diode_bridge_rectifier.ses`. + ##### Viewing the results You can view the results of the autorouting in KiCad if you have it @@ -72,7 +75,7 @@ then as follows: ``` cd tests/single_layer/data/tht_diode_bridge_rectifier/ -cargo run --features cli -- tht_diode_bridge_rectifier.dsn tht_diode_bridge_rectifier.ses +cargo run --features cli -- tht_diode_bridge_rectifier.dsn ``` Viewing the results is obviously the same. diff --git a/src/bin/topola/main.rs b/src/bin/topola/main.rs index 1e006f0..52398d2 100644 --- a/src/bin/topola/main.rs +++ b/src/bin/topola/main.rs @@ -14,7 +14,8 @@ use topola::specctra::design::SpecctraDesign; #[command(about, version)] struct Cli { input: PathBuf, - output: PathBuf, + #[arg(short, long, value_name = "FILE")] + output: Option, #[arg(short, long, value_name = "FILE")] commands: Option, } @@ -22,7 +23,7 @@ struct Cli { fn main() -> Result<(), std::io::Error> { let args = Cli::parse(); - let design_file = File::open(args.input)?; + let design_file = File::open(&args.input)?; let mut design_bufread = BufReader::new(design_file); let design = SpecctraDesign::load(design_bufread).unwrap(); @@ -41,7 +42,10 @@ fn main() -> Result<(), std::io::Error> { let mut invoker = Invoker::new(Autorouter::new(board).unwrap()); invoker.replay(history); - let mut file = File::create(args.output).unwrap(); + let output_filename = args + .output + .unwrap_or_else(|| args.input.clone().with_extension("ses")); + let mut file = File::create(output_filename).unwrap(); design.write_ses(invoker.autorouter().board(), &mut file); Ok(())