mod archive;
mod cat;
mod error;
mod extract;
mod ls;
use clap::{Parser, Subcommand};
pub(crate) const SHORT_VERSION: &str = concat!("v", env!("CARGO_PKG_VERSION"));
#[derive(Debug, Parser)]
#[command(author, version = SHORT_VERSION, long_version = SHORT_VERSION, about = "car-utils", long_about = None)]
struct Cli {
#[clap(subcommand)]
command: Commands,
}
#[derive(Debug, Subcommand)]
pub enum Commands {
#[command(name = "ar")]
Archive(archive::ArchiveCommand),
#[command(name = "cat")]
Cat(cat::CatCommand),
#[command(name = "ls")]
Ls(ls::LsCommand),
#[command(name = "cid")]
Cid(ls::LsCommand),
#[command(name = "ex")]
Ex(extract::ExCommand),
}
fn main() {
let opt = Cli::parse();
if let Err(err) = match opt.command {
Commands::Archive(command) => command.execute(),
Commands::Cat(command) => command.execute(),
Commands::Ls(command) => command.execute(false),
Commands::Cid(command) => command.execute(true),
Commands::Ex(command) => command.execute(),
} {
eprintln!("Error: {err:?}");
std::process::exit(1);
}
}