Clap
github.com
1
Leaving SiteNav
External Link Disclaimer
You are about to visit github.com. This website is not operated by us. We are not responsible for its content or privacy practices.
About this website
Clap (Command Line Argument Parser) is a fast, feature-rich, and ergonomic command-line argument parser for Rust, developed by Kevin K. and the open-source community. It is the most widely-used CLI parsing library in the Rust ecosystem, serving as the foundation for command-line tools produced by major projects including Rustup, Cargo plugins, Ripgrep, Tokei, and thousands of other Rust applications. Clap is designed around two primary APIs: the Derive API (using Rust proc macros for declarative, type-safe argument definitions via the clap derive feature) and the Builder API (a fluent, programmatic approach for dynamic argument configuration). The Derive API is the recommended approach for most use cases, allowing developers to define CLI arguments by annotating Rust structs with attributes like the arg or short and long flags, with automatic type conversion and validation. Key features include: automatic help and version flag generation with customizable formatting, subcommand support with unlimited nesting depth, POSIX and GNU-style short and long flag parsing, support for positional arguments, optional and required argument validation, default values, value ranges and possible value enumeration, custom validators for argument values, environment variable fallback for arguments (reading from env vars when not provided on the command line), shell completion script generation for Bash, Zsh, Fish, PowerShell, and Elvish, command and argument aliases, colorized help output, grouped arguments for organized usage messages, and conflict detection between mutually exclusive arguments. Clap v4 introduced significant performance improvements, reducing parse time by leveraging compile-time code generation. As of 2026, Clap has over 14,000 GitHub stars and is dual-licensed under MIT and Apache 2.0.
Tags & Categories
Categories
Tags
Statistics
1
Views
0
Clicks
0
Like
0
Dislike