use clap::{Args, Parser, Subcommand};
use std::path::PathBuf;
const MITTS_VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), " (", env!("MITTS_GIT_SHA"), ")");
#[derive(Parser, Debug)]
#[command(name = "mitts")]
#[command(author = "Alexander Panasenko <alex@prod.codes>")]
#[command(version = MITTS_VERSION)]
#[command(
about = "Rust-first build and package tooling with a shared artifact cache",
after_help = "Diagnostic Environment Variables:\n MITTS_TIMINGS=1 Enable sub-millisecond phase timings and I/O metrics on stderr\n MITTS_NO_REFLINK=1 Disable CoW reflink (FICLONE/clonefile) to force byte copying\n MITTS_NO_HARDLINK=1 Disable intra-workspace zero-copy hardlinks"
)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
Build(BuildArgs),
Check(CheckArgs),
Clippy(ClippyArgs),
Fmt(FmtArgs),
Test(TestArgs),
Coverage(CoverageArgs),
LlvmCov(CoverageArgs),
Run(RunArgs),
Explain(ExplainArgs),
Fetch(FetchArgs),
Gc(GcArgs),
Clean(CleanArgs),
}
#[derive(Args, Debug, Clone, Default)]
pub struct CleanArgs {
#[arg(long)]
pub manifest_path: Option<PathBuf>,
#[arg(long)]
pub target_dir: Option<PathBuf>,
#[arg(short, long)]
pub release: bool,
#[arg(long)]
pub cache: bool,
#[arg(long)]
pub cache_dir: Option<PathBuf>,
}
#[derive(Args, Debug, Clone, Default)]
pub struct BuildArgs {
#[arg(long)]
pub manifest_path: Option<PathBuf>,
#[arg(short, long)]
pub package: Option<String>,
#[arg(short, long)]
pub release: bool,
#[arg(long)]
pub target_dir: Option<PathBuf>,
#[arg(short = 'F', long)]
pub features: Vec<String>,
#[arg(long)]
pub no_default_features: bool,
#[arg(long)]
pub all_features: bool,
#[arg(long)]
pub no_cache: bool,
#[arg(long)]
pub cache_dir: Option<PathBuf>,
#[arg(long)]
pub native: bool,
#[arg(long)]
pub cargo: bool,
#[arg(short, long, action = clap::ArgAction::Count)]
pub verbose: u8,
#[arg(long, action = clap::ArgAction::Append)]
pub config: Vec<String>,
#[arg(long, value_name = "SPEC", action = clap::ArgAction::Append)]
pub exclude: Vec<String>,
#[arg(long = "bin", action = clap::ArgAction::Append)]
pub bin: Vec<String>,
#[arg(long)]
pub bins: bool,
#[arg(long)]
pub lib: bool,
#[arg(last = true)]
pub extra_args: Vec<String>,
}
#[derive(Args, Debug, Clone, Default)]
pub struct RunArgs {
#[command(flatten)]
pub build_args: BuildArgs,
#[arg(skip)]
pub trailing_args: Vec<String>,
}
#[derive(Args, Debug, Clone, Default)]
pub struct ExplainArgs {
#[arg(long)]
pub manifest_path: Option<PathBuf>,
#[arg(short, long)]
pub package: Option<String>,
#[arg(short, long)]
pub release: bool,
#[arg(short = 'F', long)]
pub features: Vec<String>,
#[arg(long)]
pub no_default_features: bool,
#[arg(long)]
pub all_features: bool,
#[arg(long)]
pub json: bool,
#[arg(long, value_name = "FILE")]
pub keys: Option<PathBuf>,
}
#[derive(Args, Debug, Clone, Default)]
pub struct FetchArgs {
#[arg(long)]
pub manifest_path: Option<PathBuf>,
#[arg(long)]
pub cache_dir: Option<PathBuf>,
#[arg(long)]
pub offline: bool,
#[arg(long)]
pub locked: bool,
#[arg(long)]
pub frozen: bool,
}
#[derive(Args, Debug, Clone, Default)]
pub struct GcArgs {
#[arg(long)]
pub cache_dir: Option<PathBuf>,
#[arg(long)]
pub max_bytes: Option<u64>,
#[arg(long)]
pub max_age_secs: Option<u64>,
}
pub mod build;
pub mod check;
pub mod clippy;
pub mod coverage;
pub mod coverage_tools;
pub mod coverage_types;
pub mod diagnostic;
pub mod fmt;
pub mod handlers;
pub mod run;
pub mod terminal;
pub mod test;
pub mod test_doctest;
pub mod test_runner;
pub mod ui;
pub use build::handle_build;
pub use check::{handle_check, CheckArgs};
pub use clippy::{handle_clippy, ClippyArgs};
pub use coverage::{handle_coverage, CoverageArgs};
pub use diagnostic::render_compiler_diagnostics;
pub use fmt::{handle_fmt, FmtArgs};
pub use handlers::{handle_clean, handle_explain, handle_fetch, handle_gc};
pub use run::handle_run;
pub use terminal::TerminalGuard;
pub use test::{handle_test, TestArgs};
pub use ui::Ui;