Command line argument parser for Rust, declarative (derive) or procedural (builder)
open sourceMIT OR Apache-2.0self-hostablefree
clap is the most widely used command line argument parser for Rust. You define a CLI declaratively with its derive macros or procedurally with its builder API, and users get a polished experience out of the box: common argument behaviour, generated help, suggested fixes for typos, coloured output and shell completions (with the companion clap_complete crate). It aims to be flexible enough to port an existing CLI interface, with reasonable parse performance. It's dual-licensed MIT or Apache 2.0 and funded through Open Collective.
Problems it solves
- parse command line arguments in my Rust program
- generate --help output and shell completions for a Rust CLI
- define CLI flags and subcommands with a struct and derive macro
- build a Rust CLI with subcommands
Features
- derive macros and a builder API
- generated help
- suggested fixes for mistyped arguments
- coloured output
- shell completions via clap_complete
- subcommands
