Repolode
clap-rs

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. 1

    Add clap to your Rust project

    cargo add clap

In collections

Topics

#rust#command-line#argument-parsing#cli#subcommands#argument-parser#command-line-parser#parsed-arguments#positional-arguments

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