mirror of https://codeberg.org/topola/topola.git
cli: add help/manpages (#29)
Fixes https://codeberg.org/topola/topola/issues/24 Reviewed on https://codeberg.org/topola/topola/pulls/29 Co-authored-by: Hakki <hakki@noreply.codeberg.org> Co-committed-by: Hakki <hakki@noreply.codeberg.org>
This commit is contained in:
parent
63d3e345aa
commit
817fd5e57f
|
|
@ -24,3 +24,7 @@ Cargo.lock
|
|||
|
||||
# ---> Topola
|
||||
*.ses
|
||||
dist/
|
||||
|
||||
# ignore manpages
|
||||
topola.1
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "topola"
|
||||
description = "Topological PCB router"
|
||||
description = "Work-in-progress free and open-source topological (rubberband) router and autorouter for printed circuit boards (PCBs)"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
default-run = "topola"
|
||||
|
|
@ -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"] }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
include!("src/bin/topola/cli.rs");
|
||||
use clap_mangen::Man;
|
||||
use clap::CommandFactory;
|
||||
use std::fs::{File, create_dir_all};
|
||||
// https://rust-cli.github.io/book/in-depth/docs.html
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let cmd = Cli::command();
|
||||
let man = Man::new(cmd);
|
||||
let folder = "man";
|
||||
create_dir_all(folder)?;
|
||||
let mut file = File::create(format!("{}/topola.1", folder))?;
|
||||
man.render(&mut file)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -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) input file for the Topola autorouter")]
|
||||
pub input: PathBuf,
|
||||
#[arg(short, long, value_name = "SPECCTRA SESSION FILE",
|
||||
help = "Specify the output session file in Specctra-compatible format (*.ses). The input filename is used by default, with the extension changed to Specctra Session File extension")
|
||||
]
|
||||
pub output: Option<PathBuf>,
|
||||
#[arg(short, long, value_name = "COMMAND FILE", help = "JSON-like file with .cmd extension, containing sequence of available commands ")]
|
||||
pub commands: Option<PathBuf>,
|
||||
}
|
||||
|
|
@ -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,11 @@ use topola::autorouter::selection::PinSelection;
|
|||
use topola::autorouter::Autorouter;
|
||||
use topola::specctra::design::SpecctraDesign;
|
||||
|
||||
#[derive(Parser, Debug, Default)]
|
||||
#[command(about, version)]
|
||||
struct Cli {
|
||||
input: PathBuf,
|
||||
#[arg(short, long, value_name = "FILE")]
|
||||
output: Option<PathBuf>,
|
||||
#[arg(short, long, value_name = "FILE")]
|
||||
commands: Option<PathBuf>,
|
||||
}
|
||||
pub mod cli;
|
||||
use cli::Cli;
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue