Find your next open-source project

Search by name, purpose, or keyword — or paste a GitHub repository URL

clap-rs/clap

Developer Tools

A fast, feature-rich command-line argument parser library for Rust programs, with derive and builder APIs.

16,873
1,294
Rust
Apache-2.0
11 years old

Overview

clap is a command-line argument parser for Rust. It lets a program declare its options, positional arguments, subcommands, and help text, and then handles parsing, validation, and usage output. The API supports both a declarative/derive style and a procedural builder style, so the same library fits small tools and larger multi-subcommand CLIs.

It is aimed at Rust developers who need standard CLI behavior—short and long flags, subcommands, and generated help—without writing parsing code themselves.

Get Started

With a Rust toolchain and Cargo available, add the crate from the project directory:

$ cargo add clap

Then define the parser in code. The README points to the full API reference and a set of runnable examples:

The examples are the practical starting point for seeing how declarations map to flags, subcommands, and parsed values.

Usage Constraints

The library is written for Rust projects and is consumed through Cargo; the README's installation path is cargo add clap. It is dual-licensed under Apache 2.0 or MIT, so either license can be used.

The README itself is brief and does not include a complete code walkthrough or feature compatibility matrix; the documentation and examples are where the concrete API details live.

HotRepo's take

clap has a long history on GitHub, created in 2015, and the recorded weekly Rust snapshot for 2026-11-06 shows 16,862 stars, 1,294 forks, 150 stars gained that week, and a best position of 13 on the Rust weekly list. That positions it as a long-running, actively used library in the Rust ecosystem rather than a new project. The snapshot is a single weekly data point, so it supports current activity but not a trend claim; the project's standing rests on its role as a general-purpose argument parser with a mature documentation site and examples.

Written by AI from the project's README, updated . The project's own docs are the source of truth.

Hacker News