All Projects → clap-rs → Clap

clap-rs / Clap

Licence: other
Create your command-line parser, with all of the bells and whistles, declaratively or procedurally.

Programming Languages

rust
11053 projects
Makefile
30231 projects

Projects that are alternatives of or similar to Clap

Clikt
Multiplatform command line interface parsing for Kotlin
Stars: ✭ 1,658 (-76.89%)
Mutual labels:  command-line, command-line-parser, argument-parser, argument-parsing
Picocli
Picocli is a modern framework for building powerful, user-friendly, GraalVM-enabled command line apps with ease. It supports colors, autocompletion, subcommands, and more. In 1 source file so apps can include as source & avoid adding a dependency. Written in Java, usable from Groovy, Kotlin, Scala, etc.
Stars: ✭ 3,286 (-54.2%)
Mutual labels:  command-line, command-line-parser, argument-parsing, subcommands
Argumentparser
Faster, easier, more declarative parsing of command line arguments in Objective-C/Foundation.
Stars: ✭ 251 (-96.5%)
Mutual labels:  command-line, command-line-parser, argument-parser, argument-parsing
Caporal.js
A full-featured framework for building command line applications (cli) with node.js
Stars: ✭ 3,279 (-54.29%)
Mutual labels:  command-line, command-line-parser, argument-parser, argument-parsing
Clipp
easy to use, powerful & expressive command line argument parsing for modern C++ / single header / usage & doc generation
Stars: ✭ 687 (-90.42%)
Mutual labels:  command-line, argument-parser, argument-parsing
Argh
Argh! A minimalist argument handler.
Stars: ✭ 752 (-89.52%)
Mutual labels:  command-line, command-line-parser, argument-parser
declarative-parser
Modern, declarative argument parser for Python 3.6+
Stars: ✭ 31 (-99.57%)
Mutual labels:  argument-parser, argument-parsing, command-line-parser
Argparse.jl
Package for parsing command-line arguments to Julia programs.
Stars: ✭ 131 (-98.17%)
Mutual labels:  command-line, argument-parser, argument-parsing
option-parser
A Lightweight, header-only CLI option parser for C++
Stars: ✭ 16 (-99.78%)
Mutual labels:  argument-parser, command-line-parser
args-parser
args-parser is a small C++ header-only library for parsing command line arguments.
Stars: ✭ 53 (-99.26%)
Mutual labels:  argument-parser, subcommands
structopt-toml
An default value loader from TOML for structopt
Stars: ✭ 23 (-99.68%)
Mutual labels:  argument-parsing, command-line-parser
typed-argument-parser
Typed argument parser for Python
Stars: ✭ 259 (-96.39%)
Mutual labels:  argument-parser, argument-parsing
dropt
dropt is yet another C library for parsing command-line options.
Stars: ✭ 39 (-99.46%)
Mutual labels:  argument-parser, command-line-parser
yargs-interactive
Interactive support for yargs
Stars: ✭ 40 (-99.44%)
Mutual labels:  argument-parsing, parsed-arguments
minimist2
TypeScript/JavaScript ES6 rewrite of popular Minimist argument parser
Stars: ✭ 20 (-99.72%)
Mutual labels:  argument-parser, command-line-parser
argen
Generate argument parsing logic in C from a simple config
Stars: ✭ 14 (-99.8%)
Mutual labels:  argument-parsing, parsed-arguments
AnyOption
C/C++ Command line and resource file option parsing
Stars: ✭ 83 (-98.84%)
Mutual labels:  argument-parser, argument-parsing
ArgMacros.jl
Fast, flexible, macro-based, Julia package for parsing command line arguments.
Stars: ✭ 29 (-99.6%)
Mutual labels:  argument-parser, argument-parsing
Getopt Php
A PHP library for command-line argument processing
Stars: ✭ 305 (-95.75%)
Mutual labels:  command-line, argument-parser
Structopt
Parse command line arguments by defining a struct
Stars: ✭ 323 (-95.5%)
Mutual labels:  command-line, argument-parser

clap

Command Line Argument Parser for Rust

Crates.io Crates.io License License Build Status Coverage Status Contributors

Dual-licensed under Apache 2.0 or MIT.

  1. About
  2. Tutorial: Builder API, Derive API
  3. Examples
  4. API Reference
  5. CHANGELOG
  6. FAQ
  7. Questions & Discussions
  8. Contributing
  9. Sponsors

About

Create your command-line parser, with all of the bells and whistles, declaratively or procedurally.

Example

use clap::Parser;

/// Simple program to greet a person
#[derive(Parser, Debug)]
#[clap(about, version, author)]
struct Args {
    /// Name of the person to greet
    #[clap(short, long)]
    name: String,

    /// Number of times to greet
    #[clap(short, long, default_value_t = 1)]
    count: u8,
}

fn main() {
    let args = Args::parse();

    for _ in 0..args.count {
        println!("Hello {}!", args.name)
    }
}

Add this to Cargo.toml:

[dependencies]
clap = { version = "3.0.0-rc.7", features = ["derive"] }
$ demo --help
clap [..]

A simple to use, efficient, and full-featured Command Line Argument Parser

USAGE:
    demo[EXE] [OPTIONS] --name <NAME>

OPTIONS:
    -c, --count <COUNT>    Number of times to greet [default: 1]
    -h, --help             Print help information
    -n, --name <NAME>      Name of the person to greet
    -V, --version          Print version information

(version number and .exe extension on windows replaced by placeholders)

Aspirations

  • Out of the box, users get a polished CLI experience
    • Including common argument behavior, help generation, suggested fixes for users, colored output, shell completions, etc
  • Flexible enough to port your existing CLI interface
    • However, we won't necessarily streamline support for each use case
  • Reasonable parse performance
  • Resilient maintainership, including
    • Willing to break compatibility rather than batching up breaking changes in large releases
    • Leverage feature flags to keep to one active branch
    • Being under WG-CLI to increase the bus factor
  • We follow semver and will wait about 6-9 months between major breaking changes
  • We will support the last two minor Rust releases (MSRV, currently 1.54.0)

While these aspirations can be at odds with fast build times and low binary size, we will still strive to keep these reasonable for the flexibility you get. Check out the argparse-benchmarks for CLI parsers optimized for other use cases.

Related Projects

Feature Flags

Default Features

  • std: Not Currently Used. Placeholder for supporting no_std environments in a backwards compatible manner.
  • color: Turns on colored error messages.
  • suggestions: Turns on the Did you mean '--myoption'? feature for when users make typos.

Optional features

  • derive: Enables the custom derive (i.e. #[derive(Parser)]). Without this you must use one of the other methods of creating a clap CLI listed above.
  • cargo: Turns on macros that read values from CARGO_* environment variables.
  • env: Turns on the usage of environment variables during parsing.
  • regex: Enables regex validators.
  • unicode: Turns on support for unicode characters (including emoji) in arguments and help messages.
  • wrap_help: Turns on the help text wrapping feature, based on the terminal size.

Experimental features

Warning: These may contain breaking changes between minor releases.

Sponsors

Gold

Silver

Bronze

Backer

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].