#![warn(clippy::pedantic, clippy::nursery)]
use clap::{Parser, Subcommand};
use clap_verbosity_flag::{InfoLevel, Verbosity};
use env_logger::WriteStyle;
use log::trace;
use blue_build::{
self,
commands::{build, local, template, BlueBuildCommand},
};
#[cfg(feature = "init")]
use blue_build::commands::init;
#[derive(Parser, Debug)]
#[command(name = "BlueBuild", author, version, about, long_about = None)]
struct BlueBuildArgs {
#[command(subcommand)]
command: CommandArgs,
#[clap(flatten)]
verbosity: Verbosity<InfoLevel>,
}
#[derive(Debug, Subcommand)]
enum CommandArgs {
Build(build::BuildCommand),
Template(template::TemplateCommand),
Upgrade(local::UpgradeCommand),
Rebase(local::RebaseCommand),
#[cfg(feature = "init")]
Init(init::InitCommand),
#[cfg(feature = "init")]
New(init::NewCommand),
}
fn main() {
let args = BlueBuildArgs::parse();
env_logger::builder()
.filter_level(args.verbosity.log_level_filter())
.filter_module("hyper::proto", log::LevelFilter::Info)
.write_style(WriteStyle::Always)
.init();
trace!("{args:#?}");
match args.command {
#[cfg(feature = "init")]
CommandArgs::Init(mut command) => command.run(),
#[cfg(feature = "init")]
CommandArgs::New(mut command) => command.run(),
CommandArgs::Template(mut command) => command.run(),
CommandArgs::Build(mut command) => command.run(),
CommandArgs::Rebase(mut command) => command.run(),
CommandArgs::Upgrade(mut command) => command.run(),
}
}