use clap::{CommandFactory, Parser, Subcommand};
mod commands;
mod source;
use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
struct Cli {
#[command(subcommand)]
command: Option<Commands>,
}
#[derive(Subcommand, Debug)]
enum Commands {
Export(commands::export::ExportArgs),
List(commands::list::ListArgs),
}
fn main() {
let cli = Cli::parse();
match &cli.command {
Some(Commands::Export(args)) => {
if let Err(e) = commands::export::run(args.clone()) {
eprintln!("Error: {}", e);
std::process::exit(1);
}
}
Some(Commands::List(args)) => {
if let Err(e) = commands::list::run(args.clone()) {
eprintln!("Error: {}", e);
std::process::exit(1);
}
}
None => {
let mut cmd = Cli::command();
cmd.print_help().unwrap();
}
}
}