_cookbook |
|
|
_derive |
|
|
_faq.rs |
|
6469 |
_features.rs |
|
1809 |
_tutorial |
|
|
bin |
|
|
lib.rs |
> **Command Line Argument Parser for Rust**
Quick Links:
- Derive [tutorial][_derive::_tutorial::chapter_0] and [reference][_derive]
- Builder [tutorial][_tutorial::chapter_0] and [reference](index.html)
- [Cookbook][_cookbook]
- [FAQ][_faq]
- [Discussions](https://github.com/clap-rs/clap/discussions)
- [CHANGELOG](https://github.com/clap-rs/clap/blob/v4.5.16/CHANGELOG.md) (includes major version migration
guides)
## 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](https://github.com/clap-rs/clap/tree/master/clap_complete), 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](https://github.com/rust-cli/team/) 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.74)
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](https://github.com/rust-cli/argparse-benchmarks-rs) for
CLI parsers optimized for other use cases.
## Example
Run
```console
$ cargo add clap --features derive
```
*(See also [feature flag reference][_features])*
Then define your CLI in `main.rs`:
```rust
# #[cfg(feature = "derive")] { |
4381 |