use std::path::Path;
use clap::{Parser, Subcommand};
use ninja_xtask::{
Exit,
commands::{build, clippy, clippy_tests, fmt, git_add, test},
};
#[derive(Parser)]
#[command(version)]
struct XTask {
#[command(subcommand)]
command: Command,
}
#[derive(Subcommand)]
enum Command {
Stage,
Build {
#[arg(short, long)]
glibc: Option<String>,
#[arg(short, long)]
release: bool,
},
}
fn main() -> Exit<()> {
let xtask = XTask::try_parse()?;
let root = Path::new(".");
match &xtask.command {
Command::Stage => {
let fmt = fmt(root);
Exit::from(fmt)?;
let clippy = clippy(root);
let clippy_tests = clippy_tests(root);
let tests = test(root);
let checks = vec![clippy, clippy_tests, tests];
Exit::from(checks)?;
let git = git_add(root);
Exit::from(git)
}
Command::Build { glibc, release } => {
let build = build(root, glibc, release);
Exit::from(build)
}
}
}