Usage is a spec, CLI, and Rust framework for defining command-line interfaces. Arguments, flags, environment variables, and config files can all be described in a portable KDL spec. Think of it as OpenAPI for CLIs: one declaration can drive parsing and every user-facing artifact.
- Generate shell completions
- Generate Markdown documentation and man pages
- Parse arguments from any language
- Scaffold a spec into CLI frameworks in different languages
- Build a typed Rust CLI with a zero-dependency runtime
See more at usage.jdx.dev.
Applications can use usage-rs to derive a typed parser and a portable Usage
spec from the same Rust declaration:
[dependencies] usage = { package = "usage-rs", version = "6" }
use usage::Cli; #[derive(Cli)] #[usage(bin = "example", version)] struct App { /// Print more detail. #[usage(short = 'v', long, count)] verbose: u8, /// Files to process. files: Vec<String>, } fn main() { let app = App::parse(); // app.verbose and app.files are ready to use }
Usage has its own derive vocabulary: use #[usage(...)] on commands, fields,
and value variants. See the Rust framework guide
and clap migration guide for
the supported mappings and intentional differences.
Sponsored by
View all sponsors
Usage's design owes a great deal to clap. Its help output and diagnostic conventions make clap migrations familiar, while Usage's native derive attributes reflect its portable spec model. clap's license is reproduced in NOTICE.md.