use std::process;
use clap::{Parser, Subcommand};
use libpybuild::{Bundle, BundleOptions, Install, InstallOptions};
#[derive(Parser, Debug)]
#[command(author, about, version)]
#[command(propagate_version = true)]
struct Cli {
#[command(subcommand)]
command: Commands,
#[command(flatten)]
verbose: clap_verbosity_flag::Verbosity,
}
#[derive(Subcommand, Debug)]
enum Commands {
Bundle(BundleOptions),
Install(InstallOptions),
}
fn main() {
let cli = Cli::parse();
env_logger::Builder::new()
.filter_level(cli.verbose.log_level_filter())
.init();
match &cli.command {
Commands::Bundle(bundle) => {
if let Err(err) = bundle.execute() {
eprintln!("{err}");
process::exit(2);
}
}
Commands::Install(install) => {
if let Err(err) = install.execute() {
eprintln!("{err}");
process::exit(2);
}
}
}
}