diff --git a/.gitignore b/.gitignore index 71bfe8b..831cde5 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,7 @@ Cargo.lock # ---> Topola *.ses +dist/ + +# ignore manpages +topola.1 diff --git a/Cargo.toml b/Cargo.toml index b1c2b29..ac691b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -122,3 +122,7 @@ opt-level = 2 [patch.crates-io] contracts = { path = "vendored/contracts" } + +[build-dependencies] +clap_mangen = "0.2.23" +clap = {version="4.5.8", features = ["derive"] } diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..0a2fe07 --- /dev/null +++ b/build.rs @@ -0,0 +1,11 @@ +include!("src/bin/topola/cli.rs"); +use clap_mangen::Man; +use clap::CommandFactory; +use std::fs::File; +fn main() -> Result<(), Box> { + let cli = Cli::command(); + let man = Man::new(cli); + let mut file = File::create(concat!("assets", "/topola.1"))?; + man.render(&mut file)?; + Ok(()) +} diff --git a/scripts/man_gen.sh b/scripts/man_gen.sh deleted file mode 100644 index 813c5db..0000000 --- a/scripts/man_gen.sh +++ /dev/null @@ -1,6 +0,0 @@ -#! /bin/bash -help2man topola -s 1 -o topola.1 --no-info -n "topological router and autorouter for printed circuit boards" -gzip topola.1 - -# to test purposes -# sudo cp topola.1.gz /usr/share/man/man1 diff --git a/src/bin/topola/cli.rs b/src/bin/topola/cli.rs new file mode 100644 index 0000000..d0c58cc --- /dev/null +++ b/src/bin/topola/cli.rs @@ -0,0 +1,17 @@ +use clap::Parser; +use std::path::PathBuf; + + +#[derive(Parser, Debug, Default)] +#[command(about, version)] +pub struct Cli { + #[arg(value_name = "SPECCTRA DESIGN FILE", + help = "Specify the Specctra Design (*.dsn) file input file for the Topola autorouter")] + pub input: PathBuf, + #[arg(short, long, value_name = "FILE", + help = "Specify the output Topola session file (*.ses)") + ] + pub output: Option, + #[arg(short, long, value_name = "FILE", help = "TODO")] + pub commands: Option, +} diff --git a/src/bin/topola/main.rs b/src/bin/topola/main.rs index 0c0ebda..a5b4976 100644 --- a/src/bin/topola/main.rs +++ b/src/bin/topola/main.rs @@ -1,8 +1,6 @@ -use clap::{Error, Parser}; +use clap::Parser; use std::fs::File; -use std::io::prelude::*; use std::io::BufReader; -use std::path::PathBuf; use topola::autorouter::history::History; use topola::autorouter::invoker::Command; use topola::autorouter::invoker::Invoker; @@ -10,19 +8,9 @@ use topola::autorouter::selection::PinSelection; use topola::autorouter::Autorouter; use topola::specctra::design::SpecctraDesign; -#[derive(Parser, Debug, Default)] -#[command(about, version)] -struct Cli { - #[arg(value_name = "SPECCTRA DESIGN FILE", - help = "Specify the Specctra Design (*.dsn) file input file for the Topola autorouter")] - input: PathBuf, - #[arg(short, long, value_name = "FILE", - help = "Specify the output Topola session file (*.ses)") - ] - output: Option, - #[arg(short, long, value_name = "FILE", help = "TODO")] - commands: Option, -} +// TODO: should this or include macro be used? +pub mod cli; +use cli::Cli; fn main() -> Result<(), std::io::Error> { let args = Cli::parse();