expression
Document application-specific usage exit codes
A CLI can define a small numeric code for invalid usage as part of its public contract. Here 2 is this application’s documented choice, not a Rust-wide rule. Return it at the outer boundary, with an explanatory stderr message and no success output. Fixture: Expected stdout (not executed): (empty) Expected stderr: 'usage: report --limit NUMBER\n' Expected exit: 2 Common mistake: Assuming every program uses the same numeric status for bad arguments.
Formal Syntax & Structure
rust syntaxrust
ExitCode::from(2)Working Example
Example Snippetrust
fn main() -> std::process::ExitCode { eprintln!("usage: report --limit NUMBER"); std::process::ExitCode::from(2)}