Analyzer::Rust::Cli
Inherits CliEndpointSupport < Analyzer < FileHelper < Reference < Object
Surfaces the command-line attack surface of Rust programs as cli://
endpoints: one endpoint per (sub)command with named options
(param_type "flag"), positional arguments ("argument") and consumed
environment variables ("env"). Covers std::env::args/var plus the
clap / structopt / argh derive macros and the getopts builder API
(Options::new() + opts.optopt/optflag/optflagopt/optmulti/reqopt).
Scope notes (follow-ups): the clap builder API (Command::new(...) .arg(Arg::new(...))) is only recognized as a CLI signal, not parsed into
args — a line-scan can't reliably track its method-chain/paren scoping.
A #[command(flatten)] struct's flags surface on the root rather than
on the command that flattens it.
Line-scan analyzer (Go/Python CLI house style) with a cross-file URL-merge, instead of the tree-sitter analyze_file path the HTTP Rust analyzers use. Subclasses Analyzer directly (RustEngine#analyze_file is abstract) and reuses RustEngine.test_path? as a class method.
Constants
clap builder marker (used only to recognise a builder-style CLI; the
builder arg/subcommand tree is a follow-up — see the note in analyze).
clap/structopt field attribute, e.g. #[arg(short, long, env = "X")].
builtin.
getopts: a flat (no-subcommand) builder API. let mut opts = Options::new(); binds a receiver variable, then opts.optopt(short, long, desc, hint) / optflag(short, long, desc) /
optflagopt(short, long, desc, hint) / optmulti(short, long, desc, hint) / reqopt(short, long, desc, hint) register each option on it.
The optional type-annotation group tolerates a getopts:: prefix
(let mut opts: getopts::Options = ...), matching the same prefix
already tolerated before Options::new.
A diamond of shared enums multiplies paths; real CLIs stay far below this.
#[command(subcommand)] (clap 4) / #[clap(subcommand)] / #[structopt(subcommand)].
method: UsersMethod / method: Option<UsersMethod> / pub cmd: sub::Cmd.
Web crates: their env::var reads are config, not a CLI surface.
Class methods
Instance methods
Instance-side view of the same declaration. The per-file rescues live on
this base class, which has no way to name the analyzer that is running
inside them, so a skipped file could not be attributed to a tech.
Deriving it from analyzer_for keeps the name written exactly once.