expression
Keep CLI help and examples consistent
Document the command, accepted options, data output, exit statuses and at least one safe example. Treat help as a public interface. This miniature dependency-free CLI emits a stable help string and refuses unexpected arguments. The runner passes --help in its own case; no real inventory is changed. Fixture: arguments ["--help"]. Expected stdout (not executed): Usage: inventory --help Show this help; exit 0. Expected stderr: (empty) Expected exit: 0 Common mistake: Documenting a flag that is not accepted by the executable.
Formal Syntax & Structure
rust syntaxrust
--help / --versionWorking Example
Example Snippetrust
fn main() -> std::process::ExitCode { use std::process::ExitCode; match std::env::args().nth(1).as_deref() { Some("--help") => { println!("Usage: inventory --help\nShow this help; exit 0."); ExitCode::SUCCESS } _ => { eprintln!("use --help"); ExitCode::from(2) } }}