mod schema;
mod term;
mod tool;
use clap::{command, Parser, Subcommand};
#[derive(Parser)]
#[command(author, version, about = "SBE schema tool", long_about = None, propagate_version = true)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
#[command(subcommand)]
Schema(schema::Commands),
#[command(subcommand)]
Tool(tool::Commands),
}
fn main() {
let cli = Cli::parse();
let result = match cli.command {
Commands::Schema(args) => schema::handle(args),
Commands::Tool(args) => tool::handle(args),
};
if let Err(e) = &result {
if term::error(&format!("{e}")).is_err() {
eprintln!("{e}");
}
}
_ = term::reset();
match result {
Ok(_) => std::process::exit(exitcode::OK),
Err(_) => std::process::exit(exitcode::DATAERR),
}
}