Rust: Printing a short CLI usage message with clap
Clap can print a short usage message rather than the full help text. File: Cargo.toml [package] edition = "2021" # --snip-- [dependencies] clap = { version = "4.4.0", features = ["derive"] } File: src/main.rs use clap::CommandFactory; use clap::Parser; #[derive(Parser)] struct Cli { /// First arg arg1: String, /// Second arg arg2: Vec<String>, } fn main() { let mut cmd = Cli::command(); println!("{}", cmd.render_usage()); } Result al@linux ~ $ ./clap_test Usage: clap_test <ARG1> [ARG2]....