use clap::Parser;
use mitts::cli::{
handle_bench, handle_build, handle_check, handle_clean, handle_clippy, handle_coverage,
handle_explain, handle_fetch, handle_fmt, handle_gc, handle_metadata, handle_package,
handle_publish, handle_run, handle_rustc, handle_test, Cli, Commands,
};
use std::process::ExitCode;
fn main() -> ExitCode {
let cli = Cli::parse();
if let Some(jobs) = cli.command.jobs() {
mitts::core::jobs::set_flag_limit(jobs);
}
let code = match cli.command {
Commands::Build(ref args) => handle_build(args),
Commands::Rustc(ref args) => handle_rustc(args),
Commands::Check(ref args) => handle_check(args),
Commands::Clippy(ref args) => handle_clippy(args),
Commands::Fmt(ref args) => handle_fmt(args),
Commands::Test(ref args) => handle_test(args),
Commands::Bench(ref args) => handle_bench(args),
Commands::Coverage(ref args) => handle_coverage(args),
Commands::LlvmCov(ref args) => handle_coverage(args),
Commands::Run(ref args) => handle_run(args),
Commands::Explain(ref args) => handle_explain(args),
Commands::Metadata(ref args) => handle_metadata(args),
Commands::Fetch(ref args) => handle_fetch(args),
Commands::Package(ref args) => handle_package(args),
Commands::Publish(ref args) => handle_publish(args),
Commands::Gc(ref args) => handle_gc(args),
Commands::Clean(ref args) => handle_clean(args),
};
if code == 0 {
ExitCode::SUCCESS
} else {
ExitCode::from(code as u8)
}
}