use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(name = "cargo", bin_name = "cargo", version)]
pub struct Cargo {
#[command(subcommand)]
pub command: CargoCommand,
}
#[derive(Subcommand, Debug)]
pub enum CargoCommand {
Brief(BriefArgs),
}
#[derive(Parser, Debug, Clone)]
#[command(
version,
after_help = "\
RESOLUTION RULES:
The <TARGET> argument is resolved as follows:
1. \"self\" → current package (cwd-based detection)
2. \"self::mod\" → current package, specific module
3. \"crate::mod\" → named crate + module in one argument
4. \"src/foo.rs\" → file path auto-converted to module path
5. \"crate_name\" → workspace package (hyphen/underscore normalized)
6. \"unknown_name\" → treated as package name (use \"self::mod\" for modules)
The [MODULE_PATH] argument also accepts file paths (e.g., src/foo.rs).
SEARCH MODE:
--search <PATTERN> searches all leaf items in the crate by name.
Matching is case-insensitive substring on the full path (e.g., \"world::World::spawn\").
Multiple words are AND-matched: \"World spawn\" finds items whose path contains both.
Output: one line per match with full path prefix:
fn module::Type::method(&self, arg: T) -> Ret;
struct module::StructName;
field module::Struct::field_name: Type;
variant module::Enum::Variant(T1, T2);
const module::CONST_NAME: Type = ..;
type module::AliasName = ActualType;
macro module::macro_name!;"
)]
pub struct BriefArgs {
#[arg(value_name = "TARGET", default_value = "self")]
pub crate_name: String,
pub module_path: Option<String>,
#[arg(long, help_heading = "Local Workspace")]
pub at_package: Option<String>,
#[arg(long, help_heading = "Local Workspace")]
pub at_mod: Option<String>,
#[arg(long, help_heading = "Local Workspace")]
pub manifest_path: Option<String>,
#[arg(long, default_value = "1")]
pub depth: u32,
#[arg(long)]
pub recursive: bool,
#[arg(long)]
pub all: bool,
#[arg(long)]
pub expand_glob: bool,
#[arg(long, value_name = "PATTERN", help_heading = "Search")]
pub search: Option<String>,
#[arg(long, value_name = "[OFFSET:]N", help_heading = "Search")]
pub search_limit: Option<String>,
#[arg(long, value_name = "TYPE", help_heading = "Search")]
pub methods_of: Option<String>,
#[arg(long, help_heading = "Filtering")]
pub no_docs: bool,
#[arg(long, help_heading = "Filtering")]
pub compact: bool,
#[arg(long, help_heading = "Filtering")]
pub no_structs: bool,
#[arg(long, help_heading = "Filtering")]
pub no_enums: bool,
#[arg(long, help_heading = "Filtering")]
pub no_traits: bool,
#[arg(long, help_heading = "Filtering")]
pub no_functions: bool,
#[arg(long, help_heading = "Filtering")]
pub no_aliases: bool,
#[arg(long, help_heading = "Filtering")]
pub no_constants: bool,
#[arg(long, help_heading = "Filtering")]
pub no_unions: bool,
#[arg(long, help_heading = "Filtering")]
pub no_macros: bool,
#[arg(long, value_name = "SPEC", help_heading = "Remote Crate (crates.io)")]
pub crates: Option<String>,
#[arg(
long,
value_name = "FEATURES",
help_heading = "Remote Crate (crates.io)"
)]
pub features: Option<String>,
#[arg(long, help_heading = "Remote Crate (crates.io)")]
pub no_cache: bool,
#[arg(long, default_value = "nightly", help_heading = "Advanced")]
pub toolchain: String,
}