For a command-line argument parser for Rust, the first results are clap-rs/clap (Clap is the most comprehensive Rust argument-parsing library, offering a derive macro for struct-based parsing, subcommand support, automatic help generation, value validation, shell completion generation, and extensive customization — exactly what you need for a CLI application), texitoi/structopt and google/argh. Compare the match explanations and check the project documentation against your requirements.
Libraries and frameworks for building robust command line interfaces and parsing arguments in Rust applications.
Clap is a command-line argument parser for Rust that enables developers to define complex interfaces through strongly-typed data structures. It functions as a comprehensive framework for building terminal applications, automating the transformation of raw string inputs into validated, type-safe code representations while simultaneously generating help documentation and usage statements. The library distinguishes itself by offering both a declarative, attribute-based approach and a fluent builder-pattern API, allowing for flexible interface construction. It includes a sophisticated validation
Clap is the most comprehensive Rust argument-parsing library, offering a derive macro for struct-based parsing, subcommand support, automatic help generation, value validation, shell completion generation, and extensive customization — exactly what you need for a CLI application.
Parse command line arguments by defining a struct.
Structopt is a Rust library that lets you define CLI arguments as a struct with a derive macro, providing automatic help generation, subcommand support, and default values, which matches the request for a command-line argument parsing library; however, it may not include built-in shell completion generation or custom error messages as part of its core feature set.
Rust derive-based argument parsing optimized for code size
argh is a Rust derive-based argument parsing library that supports struct-based parsing, subcommands, and automatic help generation, which directly fits the search for a Rust CLI argument parser — though its focus on minimal code size means it lacks built-in shell completion generation and has limited error customization compared to more full-featured options.
| Repository | Stars | Language | License | Last push |
|---|---|---|---|---|
| clap-rs/clap | 16.5K | Rust | Apache-2.0 | |
| texitoi/structopt | 2.7K | Rust | NOASSERTION | |
| google/argh | 1.9K | Rust | BSD-3-Clause |