use anyhow::Result;
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Coverage {
#[arg(short, long, default_value_t = false)]
dev: bool,
#[arg(long, default_value_t = false)]
neo: bool,
},
Ci,
Docs,
Bump {
#[arg(default_value = "patch")]
bump: String,
},
Publish,
Dist,
Rule {
#[arg(default_value = "default")]
target: String,
rule_options: Vec<String>,
},
}
pub mod ops;
pub trait Addon {
fn dist() -> Result<()> {
println!("Warning: Empty dist receipt.");
Ok(())
}
fn rule(target: String, options: Vec<String>) -> Result<()> {
println!("Warning: Empty receipt for target {target}, options: {options:?}");
Ok(())
}
}
pub trait Make: Addon {
fn make() -> Result<()> {
let cli = Cli::parse();
match &cli.command {
Commands::Ci => xtaskops::tasks::ci(),
Commands::Docs => xtaskops::tasks::docs(),
Commands::Coverage { dev, neo: false } => xtaskops::tasks::coverage(*dev),
Commands::Coverage { neo: true, .. } => ops::neo_coverage(),
Commands::Bump { bump } => ops::bump_version(bump),
Commands::Publish => ops::publish(),
Commands::Dist => Self::dist(),
Commands::Rule {
target,
rule_options,
} => Self::rule(target.clone(), rule_options.clone()),
}
}
}
impl<T> Make for T where T: Addon {}
struct MakeImpl();
impl Addon for MakeImpl {}
pub fn make() -> Result<()> {
MakeImpl::make()
}