pub mod check;
pub mod validate;
use aufbau::logic::debug::{DebugLevel, add_module_filter, set_debug_input, set_debug_level};
use clap::{ArgAction, Parser, Subcommand};
#[derive(Parser)]
#[command(name = "aufbau", version, about = "aufbau toolkit", long_about = None)]
#[command(propagate_version = true)]
pub struct Cli {
#[arg(short = 'v', long = "verbose", action = ArgAction::Count, global = true)]
pub verbose: u8,
#[arg(long = "trace", action = ArgAction::SetTrue, global = true)]
pub trace: bool,
#[arg(long = "modules", value_name = "LIST", global = true)]
pub modules: Option<String>,
#[arg(long = "with-input", action = ArgAction::SetTrue, global = true)]
pub with_input: bool,
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand)]
pub enum Commands {
Check(self::check::CheckCmd),
Validate(self::validate::ValidateCmd),
}
pub fn run() {
let cli = Cli::parse();
let level = if cli.trace {
DebugLevel::Trace
} else {
match cli.verbose {
0 => DebugLevel::Error,
1 => DebugLevel::Warn,
2 => DebugLevel::Info,
3 => DebugLevel::Debug,
_ => DebugLevel::Trace,
}
};
set_debug_level(level);
if let Some(mods) = &cli.modules {
for m in mods.split(',').map(|s| s.trim()).filter(|s| !s.is_empty()) {
add_module_filter(m);
}
}
if cli.with_input {
set_debug_input(None);
}
match &cli.command {
Commands::Check(args) => self::check::run(args),
Commands::Validate(args) => self::validate::run(args),
}
}