Skip to content

Commit afd0342

Browse files
committed
docs(readme): discuss API trade offs
Fixes #3329
1 parent 43673a1 commit afd0342

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pre-release-replacements = [
5151
{file="CHANGELOG.md", search="ReleaseDate", replace="{{date}}", min=1},
5252
{file="CHANGELOG.md", search="<!-- next-header -->", replace="<!-- next-header -->\n## [Unreleased] - ReleaseDate\n", exactly=1},
5353
{file="CHANGELOG.md", search="<!-- next-url -->", replace="<!-- next-url -->\n[Unreleased]: https://github.com/clap-rs/clap/compare/{{tag_name}}...HEAD", exactly=1},
54-
{file="README.md", search="github.com/clap-rs/clap/blob/[^/]+/", replace="github.com/clap-rs/clap/blob/{{tag_name}}/", exactly=10, prerelease = true},
54+
{file="README.md", search="github.com/clap-rs/clap/blob/[^/]+/", replace="github.com/clap-rs/clap/blob/{{tag_name}}/", exactly=12, prerelease = true},
5555
{file="README.md", search="version = \"[a-z0-9\\.-]+\"", replace="version = \"{{version}}\"", exactly=1, prerelease = true},
5656
{file="src/derive.rs", search="github.com/clap-rs/clap/blob/[^/]+/", replace="github.com/clap-rs/clap/blob/{{tag_name}}/", exactly=4, prerelease = true},
5757
]

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Create your command-line parser, with all of the bells and whistles, declarative
3333

3434
This uses our
3535
[Derive API](https://github.com/clap-rs/clap/blob/v3.0.10/examples/derive_ref/README.md)
36-
which provides access to the Builder API as attributes on a `struct`:
36+
which provides access to the [Builder API](https://docs.rs/clap) as attributes on a `struct`:
3737

3838
<!-- Copied from examples/demo.{rs,md} -->
3939
```rust,no_run
@@ -102,6 +102,20 @@ get. Check out the
102102
[argparse-benchmarks](https://github.com/rust-cli/argparse-benchmarks-rs) for
103103
CLI parsers optimized for other use cases.
104104

105+
### Selecting an API
106+
107+
Why use the declarative [Derive API](https://github.com/clap-rs/clap/blob/v3.0.10/examples/tutorial_derive/README.md):
108+
- Easier to read, write, and modify
109+
- Easier to keep the argument declaration and reading of argument in sync
110+
- Easier to reuse, e.g. [clap-verbosity-flag](https://crates.io/crates/clap-verbosity-flag)
111+
112+
Why use the procedural [Builder API](https://github.com/clap-rs/clap/blob/v3.0.10/examples/tutorial_builder/README.md):
113+
- Faster compile times if you aren't already using other procedural macros
114+
- More flexible, e.g. you can look up how many times an argument showed up,
115+
what its values were, and what were the indexes of those values. The Derive
116+
API can only report presence, number of occurrences, or values but no indices
117+
or combinations of data.
118+
105119
### Related Projects
106120

107121
- [wild](https://crates.io/crates/wild) for supporting wildcards (`*`) on Windows like you do Linux

0 commit comments

Comments
 (0)