use log::error;
use clap::{command, crate_authors, Parser, Subcommand};
use clap_verbosity_flag::{InfoLevel, Verbosity};
use crate::shadow;
pub mod bug_report;
pub mod build;
pub mod completions;
#[cfg(feature = "init")]
pub mod init;
pub mod local;
pub mod template;
pub trait BlueBuildCommand {
fn try_run(&mut self) -> anyhow::Result<()>;
fn run(&mut self) {
if let Err(e) = self.try_run() {
error!("{e}");
std::process::exit(1);
}
}
}
#[derive(Parser, Debug)]
#[clap(
name = "BlueBuild",
about,
long_about = None,
author=crate_authors!(),
version=shadow::PKG_VERSION,
long_version=shadow::CLAP_LONG_VERSION,
)]
pub struct BlueBuildArgs {
#[command(subcommand)]
pub command: CommandArgs,
#[clap(flatten)]
pub verbosity: Verbosity<InfoLevel>,
}
#[derive(Debug, Subcommand)]
pub enum CommandArgs {
Build(build::BuildCommand),
Template(template::TemplateCommand),
#[command(visible_alias("update"))]
Upgrade(local::UpgradeCommand),
Rebase(local::RebaseCommand),
#[cfg(feature = "init")]
Init(init::InitCommand),
#[cfg(feature = "init")]
New(init::NewCommand),
BugReport(bug_report::BugReportCommand),
Completions(completions::CompletionsCommand),
}