Arguments, options, and flags
Parse Rust command-line arguments with clap derive. Examples cover flags, defaults, optional values, typed validation, lists, and help text.
Arguments, subcommands, validation, output handling, shell completions, and tests for Rust command-line tools.
5 chapters · 27 topics
Parse Rust command-line arguments with clap derive. Examples cover flags, defaults, optional values, typed validation, lists, and help text.
Build clap subcommands with shared options, argument groups, conflicts, and environment defaults. Handle paths and trailing arguments.
Handle clap parse errors and exit codes in Rust. Send results to stdout, diagnostics to stderr, and write output files with examples.
Use the clap builder API for dynamic commands and advanced arguments. Add JSON output, anyhow errors, and verbosity flags to a Rust CLI.
Generate clap shell completions and man pages, test a CLI with assert_cmd, and follow a complete Rust file-search command example.
Allow Google Analytics to measure page visits and use of the guides? It uses cookies after you accept. Your choice won’t affect access to the site. Privacy notice