use std::path::PathBuf;
use clap::{Args, Parser};
#[derive(Parser, Debug)]
#[command(name = "cargo", bin_name = "cargo")]
pub(crate) enum CargoCli {
Each(EachArgs),
}
#[derive(Args, Debug, Clone)]
#[command(
version,
about = "Run a command over a cargo-style selection of workspace members",
long_about = "Resolve a cargo-style package selection (-p/--package, --workspace, --exclude), \
optionally filter it by a metadata predicate, and run a command over the result \
— once per member (with {name}/{spec}/{version}/{manifest} substitution) or once \
for the whole set (--once, with {packages})."
)]
#[expect(clippy::struct_excessive_bools, reason = "each bool is an independent clap CLI flag")]
pub(crate) struct EachArgs {
#[arg(short = 'p', long = "package", value_name = "SPEC")]
pub(crate) packages: Vec<String>,
#[arg(long, visible_alias = "all")]
pub(crate) workspace: bool,
#[arg(long, value_name = "SPEC", requires = "workspace")]
pub(crate) exclude: Vec<String>,
#[arg(long)]
pub(crate) none: bool,
#[arg(long = "filter", value_name = "PRED")]
pub(crate) filters: Vec<String>,
#[arg(long = "exclude-filter", value_name = "PRED")]
pub(crate) exclude_filters: Vec<String>,
#[arg(long)]
pub(crate) once: bool,
#[arg(long)]
pub(crate) chdir: bool,
#[arg(long)]
pub(crate) keep_going: bool,
#[arg(long)]
pub(crate) dry_run: bool,
#[arg(long, value_name = "PATH")]
pub(crate) manifest_path: Option<PathBuf>,
#[arg(last = true, required = true, value_name = "COMMAND")]
pub(crate) command: Vec<String>,
}
#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod tests {
use clap::CommandFactory;
use super::*;
#[test]
fn cli_definition_is_well_formed() {
CargoCli::command().debug_assert();
}
}