use clap::{Parser, Subcommand};
use tracing::{error, trace};
mod build;
mod utils;
mod log;
mod new;
#[derive(Debug, Parser)]
#[command(author,version,long_about = None)]
struct StartUp {
#[arg(short, long, action=clap::ArgAction::Count)]
debug: u8,
#[command(subcommand)]
commands: Commands,
}
#[derive(Debug, Subcommand)]
pub(crate) enum Commands {
New,
Build,
}
impl StartUp {
fn start_up(&self) {
trace!("{:?}", self);
match &self.commands {
Commands::New => Commands::new(),
Commands::Build => Commands::build(),
}
}
}
pub fn init() {
let cli = StartUp::parse();
log::log(cli.debug == 1);
match utils::check() {
Ok(_) => cli.start_up(),
Err(e) => {
error!("{}", e);
std::process::exit(1);
}
}
}