A Java framework for building command line apps with annotations or a programmatic API, supporting subcommands, ANSI colors and shell autocompletion.
clap-rs/clap
A full-featured Rust library for building command-line argument parsers, defined declaratively or procedurally.
- Stars
- 16,942
- Forks
- 1,308
- Open issues
- 455
- Last commit
- 5 days ago
What is it?
clap is a command-line argument parser for Rust. It lets developers define the arguments, flags, options, positional values and subcommands their program accepts, and then parses the user's input against that definition.
The parser can be configured declaratively with derive macros or procedurally through a builder API, so you can choose whichever style fits your code. Its documentation is hosted on docs.rs, and the repository includes a set of examples showing common usage patterns.
The crate is dual-licensed under Apache 2.0 and MIT, and is published on crates.io under the name clap.
Key features
- 01Declarative derive-based and procedural builder-based APIs
- 02Supports flags, options, positional arguments and subcommands
- 03Generates help and usage output for the defined command
- 04Published on crates.io and documented on docs.rs
Use cases
- Building a Rust CLI tool that needs structured argument parsing
- Adding subcommands such as git-style 'app build' or 'app run' to a program
- Defining typed command-line options with validation in a Rust application
Quick start
- 1
Add clap to your Rust project
cargo add clap
In collections
Topics
FAQ
- What is clap?
- A full-featured Rust library for building command-line argument parsers, defined declaratively or procedurally. clap is a command-line argument parser for Rust. It lets developers define the arguments, flags, options, positional values and subcommands their program accepts, and then parses the user's input against that definition.
- Is clap free to use? What license does it have?
- clap is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is clap still maintained?
- Actively maintained. The last commit to clap was on Nov 2, 2026.
- What can I use clap for?
- Building a Rust CLI tool that needs structured argument parsing Adding subcommands such as git-style 'app build' or 'app run' to a program Defining typed command-line options with validation in a Rust application
- How do I install clap?
- Add clap to your Rust project: cargo add clap
- Where can I get clap?
- The source code and installation instructions are on GitHub: https://github.com/clap-rs/clap
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A declarative Go package for building command line tools, with subcommands, flags, shell completion and help generation.
A Python toolkit for building composable command line interfaces with nested commands, automatic help pages, and lazy-loaded subcommands.
A type-safe Swift library for declaring and parsing command-line arguments, options, and flags with auto-generated help.
A line-oriented regex search tool (rg) that recursively searches directories while respecting .gitignore rules by default.
A cat(1) clone for the terminal with syntax highlighting, Git change markers, and automatic paging.