From e706134ed0a9850d0b517dfe55ed9b16fb0adabb Mon Sep 17 00:00:00 2001 From: Szpachlarz Date: Sun, 7 Jul 2024 12:05:36 +0200 Subject: [PATCH] cli: create basic cli application it is possible to load design and history, not yet possible to export results. --- Cargo.toml | 10 ++++++ dist/.stage/favicon-bb479c4c9d076525.ico | Bin 0 -> 4286 bytes src/bin/topola-cli/main.rs | 39 +++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 dist/.stage/favicon-bb479c4c9d076525.ico create mode 100644 src/bin/topola-cli/main.rs diff --git a/Cargo.toml b/Cargo.toml index 88d9216..0d05785 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,10 @@ default-run = "topola-egui" [lib] name = "topola" +[[bin]] +name = "topola-cli" +required-features = ["cli"] + [[bin]] name = "topola-egui" required-features = ["egui"] @@ -16,6 +20,7 @@ name = "topola-sdl2-demo" required-features = ["sdl2"] [features] +cli = ["dep:clap"] egui = ["dep:eframe", "dep:egui", "dep:rfd", "dep:futures"] sdl2 = ["dep:sdl2", "dep:gl", "dep:pathfinder_canvas", "dep:pathfinder_geometry", "dep:pathfinder_gl", "dep:pathfinder_renderer", "dep:pathfinder_resources"] disable_contracts = ["contracts/disable_contracts"] @@ -45,6 +50,11 @@ features = ["use-serde"] version = "1" features = ["derive"] +[dependencies.clap] +optional = true +version = "4.5.8" +features = ["derive"] + [dependencies.eframe] optional = true version = "0.26.0" diff --git a/dist/.stage/favicon-bb479c4c9d076525.ico b/dist/.stage/favicon-bb479c4c9d076525.ico new file mode 100644 index 0000000000000000000000000000000000000000..66ab34e9efc03407372090833c11e45e93f69a91 GIT binary patch literal 4286 zcmeHKO-NKx6nuQ5e)J+O#O5g;WqYg@m;T2?`SmE;-7RIQ}V>x(Ew&?J9+Lw_J^RR6T zZOA029GlIbtv~l!w*R6BBYXbDy(8p*zJCgRKK-qxnIZdLnyLQgQyUvBlkc!hbXD!z z$oqVsJiigLvARE#oN_Go<0no{GrE)I2j(%ab+62kiSF~6N15|>viz!QT;a9WWs*~l z1!og;)+Wmj+#z1;eVHSD-O2&qAaQ!V=GJ8SHSMK~^N*C4KFm!&uN{fKZ?XBzA-}(E zHd#r+X3&7Youtdv<`lUw@54a9=sSfiT?wA+#D#HLa8y-wEoR#U$*mERn;HJ_EdFE>)L_%2nP25_jfs*@jBwhxQex$BOSI&GB?-YC;3#> zJRtj$>F8l6*8kDYp`VGx<30%5K65|L#CBUZ`eJd|`!V(nmzSHXWBu{w=;H-+&v9Hx zRlDcNILueVH$?;bQuN|H=wpOOkI>g{>4~1*XXL}^#~PMM&S@(6@_`fhL64_%RV)bg zK5g@vkAx5NTWq^1Y(i2_`1)lf*&22HPmxpCqae?E#n{gu{Aw3tk~{UaFa60yWTc7tfC#-^VvR>bKH zL@EmdQM~*Md4}WXSeKF8bUq7Hf&+X_4H#Q7RSPfw-l0OoN6psfY)l-2# DucR>g literal 0 HcmV?d00001 diff --git a/src/bin/topola-cli/main.rs b/src/bin/topola-cli/main.rs new file mode 100644 index 0000000..73efe54 --- /dev/null +++ b/src/bin/topola-cli/main.rs @@ -0,0 +1,39 @@ +use std::fs::File; +use std::io::BufReader; +use std::io::prelude::*; +use clap::{Parser, Error}; + +#[derive(Parser)] +struct Cli { + input: std::path::PathBuf, + output: std::path::PathBuf, + history: Option, +} + +fn main() -> Result<(), std::io::Error> { + + let args = Cli::parse(); + + let design_file = File::open(args.input)?; + let mut design_bufread = BufReader::new(design_file); + + let design = topola::specctra::design::SpecctraDesign::load(design_bufread).unwrap(); + let board = design.make_board(); + + if let Some(history) = args.history { + let history_file = File::open(history)?; + let mut history_bufread = BufReader::new(history_file); + let mut invoker = topola::autorouter::invoker::Invoker::new( + topola::autorouter::Autorouter::new(board).unwrap()); + invoker.replay(serde_json::from_reader(history_bufread).unwrap()) + } + + Ok(()) + // let content = std::fs::read_to_string(&args.input).expect("could not read file"); + + // for line in content.lines() { + // if line.contains(&args.pattern) { + // println!("{}", line); + // } + // } +} \ No newline at end of file