mod cli;
mod commands;
mod display;
mod exit;
use cli::Command;
fn main() {
let args: Vec<String> = std::env::args().skip(1).collect();
let code = match cli::parse(&args) {
Ok(cmd) => run(cmd),
Err(usage) => {
eprintln!("{usage}");
exit::USAGE
}
};
std::process::exit(code);
}
fn run(cmd: Command) -> i32 {
match cmd {
Command::Version => {
println!("brygge {}", env!("CARGO_PKG_VERSION"));
println!("IR contract version: {}", brygge_ir::version::CURRENT);
exit::CLEAN
}
Command::Help => {
println!("{}", cli::USAGE);
exit::CLEAN
}
Command::Decode {
kind,
source,
out,
infer_renames,
reconstruct_refs,
format,
} => commands::run_decode(kind, &source, &out, infer_renames, reconstruct_refs, format),
Command::Inspect {
artifact,
atoms,
format,
} => commands::run_inspect(&artifact, atoms, format),
Command::Verify {
artifact,
against_source,
format,
} => commands::run_verify(&artifact, against_source.as_deref(), format),
}
}