#![allow(unused)]
use clap::{Args, Parser, Subcommand};
use tracing::{error, trace};
mod build;
mod log;
mod new;
mod utils;
#[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(NewArgs),
Build,
}
#[derive(Debug, Args)]
struct NewArgs {
#[arg(short, long,action=clap::ArgAction::Count)]
vite: u8,
#[arg(short, long)]
name: Option<String>,
}
impl Commands {
fn run(&self) {
match &self {
Commands::New(NewArgs { vite, name }) => Commands::new(*vite, name),
Commands::Build => Commands::build(),
}
}
}
impl StartUp {
fn start_up(&self) {
trace!("{:?}", self);
self.commands.run();
}
}
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);
}
}
}