cli: create basic cli application

it is possible to load design and history,
 not yet possible to export results.
This commit is contained in:
Szpachlarz 2024-07-07 12:05:36 +02:00
parent 2368feded1
commit e706134ed0
3 changed files with 49 additions and 0 deletions

View File

@ -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"

BIN
dist/.stage/favicon-bb479c4c9d076525.ico vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -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<std::path::PathBuf>,
}
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);
// }
// }
}