mod args;
mod dictionaries;
mod error;
mod gen;
mod generate;
mod init;
mod validate;
use clap::{Parser, Subcommand};
use std::path::PathBuf;
pub use error::CliError;
#[derive(Parser, Debug)]
#[command(name = "calib-targets")]
#[command(about = "CLI for printable calibration target generation")]
pub(crate) struct Cli {
#[command(subcommand)]
pub(crate) command: Command,
}
#[derive(Subcommand, Debug)]
pub(crate) enum Command {
Generate {
#[arg(long)]
spec: PathBuf,
#[arg(long)]
out_stem: PathBuf,
},
Validate {
#[arg(long)]
spec: PathBuf,
},
ListDictionaries,
Init {
#[command(subcommand)]
target: init::InitCommand,
},
Gen {
#[command(subcommand)]
target: gen::GenCommand,
},
}
pub fn run() -> Result<(), CliError> {
run_from(Cli::parse())
}
fn run_from(cli: Cli) -> Result<(), CliError> {
match cli.command {
Command::Generate { spec, out_stem } => generate::run(spec, out_stem),
Command::Validate { spec } => validate::run(spec),
Command::ListDictionaries => dictionaries::run(),
Command::Init { target } => init::run(target),
Command::Gen { target } => gen::run(target),
}
}