Commit graph

5774 commits

Author SHA1 Message Date
Ed Page
9caec5a52d fix(parser): Deprecate ArgMatches::is_present 2022-06-10 14:21:25 -05:00
Ed Page
d5e2622df9
Merge pull request #3813 from epage/anon
fix: Open the door for adding value_parser! specializations
2022-06-10 11:14:27 -05:00
Ed Page
cf3ad4fca6
Merge pull request #3812 from epage/discourage
fix: Further discourage `value_parser!` implementation details
2022-06-10 10:53:06 -05:00
Ed Page
f87fd0325c fix: Open the door for adding value_parser! specializations
I wanted to make the contract more clear that we might add more specific
value parsers in the future.
2022-06-10 10:52:38 -05:00
Ed Page
af0751c757 fix: Further discourage direct use of ValueParserVia* 2022-06-10 10:30:48 -05:00
Ed Page
8b37be4b01 fix: Further discourage direct use of AutoValueParser 2022-06-10 10:29:06 -05:00
Ed Page
9b7813558c feat(parser): Provide updated version if 'is_present'
- This matches the more container-like naming we are aiming for
- This provides an opportunity to warn people about moving away from
  `ArgAction::IncOcccurrences` for flags, like the deprecation for
  `ArgMatches::occurrences_of` to help people migrate in preparation for
  clap 4 (rather than having the behavior change subtly in a way only
  caught by thorough tests)

In addition, I feel `contains_id` has less ambiguous meaning than
`is_present`.
2022-06-10 10:16:44 -05:00
Ed Page
fce1125ba9 fix(assert): Allow required flags
Newstyle flags have defaults which prevents them from being required
until now.
2022-06-10 10:16:44 -05:00
Ed Page
54125aca55 docs(parser): Clarify we want arg ids
This was missed in #3453
2022-06-09 17:00:07 -05:00
Ed Page
aa9ca76b60
Merge pull request #3811 from epage/error
fix(parser): Always include pending arguments in errors
2022-06-09 13:57:03 -05:00
Ed Page
e70b3ff47b fix(parser): Always include pending arguments in errors
Found via cargo's UI tests
2022-06-09 13:41:24 -05:00
Ed Page
356ac55ce8
Merge pull request #3810 from epage/count
perf(parser): Take up less memory with ArgAction::Count
2022-06-09 12:14:56 -05:00
Ed Page
31b22d1a51 perf(parser): Take up less memory with ArgAction::Count
Someone should not reasonably expect a coun flag to go up to billions,
millions, or even thousands.  255 should be sufficient for anyone,
right?

The original type was selected to be consistent with
`ArgMatches::occurrences_of` but that is also used for tracking how
many values appear which can be large with `xargs`.

I'm still conflicted on what the "right type" is an wish we could
support any numeric type.  When I did a search on github though, every
case was for debug/quiet flags and only supported 2-3 occurrences,
making a `u8` overkill.

This came out of a discussion on #3792
2022-06-09 11:09:38 -05:00
Ed Page
acfb130b0d fix(parser): Prevent rollover of count 2022-06-09 11:05:06 -05:00
Ed Page
cb86785c7f docs: Update changelog 2022-06-09 10:47:08 -05:00
Ed Page
4b505ddf12
Merge pull request #3806 from epage/changelog
docs: Update changelog
2022-06-08 21:11:12 -05:00
Ed Page
653e121bcc
Merge pull request #3805 from epage/visibility
fix(builder): Clean up after hiding `AnyValueParser`
2022-06-08 21:10:33 -05:00
Ed Page
01b5e1ee5b perf(builder): Avoid Arc for value parsers
There isn't a strong need for the single-instance at the cost of the
extra book keeping.
2022-06-08 20:57:00 -05:00
Ed Page
d73ff562d1 fix(builder): Move trait requirements closer to the user
My hope is this will provide clearer error messages for the user.
2022-06-08 20:41:51 -05:00
Ed Page
4dc0136b2c fix(parser): Hide AnyValue
With `AnyValueParser` now private, we can also make `AnyValue` private.
Most users should not need to call `ValueParser::parse_ref` and doing
this gives us more implementation freedom for the future.
2022-06-08 20:22:39 -05:00
Ed Page
a849a28a04
Merge pull request #3804 from epage/version
fix(assert): Reslve regressions for auto-help / auto-version
2022-06-08 20:19:34 -05:00
Ed Page
ebf21a3280 fix(assert): Don't assert in more cases 2022-06-08 17:39:14 -05:00
Ed Page
c61a105e62 fix(builder): Fix regression with auto-help / auto-version 2022-06-08 17:17:50 -05:00
Ed Page
035bc804d1 fix(builder): Dump action in debug output 2022-06-08 16:39:27 -05:00
Ed Page
3052fece16 fix(builder): Make it easier to debug globals 2022-06-08 16:35:56 -05:00
Ed Page
588c46b6c6 docs: Update changelog 2022-06-08 15:04:53 -05:00
Ed Page
731408ee80
Merge pull request #3801 from SabrinaJewson/private-any-value-parser
Make `AnyValueParser` private
2022-06-08 14:56:39 -05:00
SabrinaJewson
560f0c076a
fix: Appease CI 2022-06-08 20:45:25 +01:00
SabrinaJewson
6e49bf7419
refactor: Make AnyValueParser private 2022-06-08 20:36:55 +01:00
Ed Page
b1bda293d4
Merge pull request #3802 from epage/refactor
refactor(builder): Reduce visibility
2022-06-08 14:30:15 -05:00
Ed Page
aba2a9e84d refactor(builder): Reduce visibility 2022-06-08 14:18:23 -05:00
Ed Page
4331cd29ab
Merge pull request #3800 from epage/deprecate
fix(help): Deprecate NoAutoVersion/NoAutoHelp
2022-06-08 12:39:55 -05:00
Ed Page
10bb9abb1a fix(assert): Reference help_expected 2022-06-08 12:06:15 -05:00
Ed Page
28781d6773 fix(help): Deprecate NoAutoVersion/NoAutoHelp
I'm a bit disappointed we don't have a way to control the action for the
help subcommand.  Instead, people will need to provide their own and
disable ours.  Long term, I want to design actions for subcommands but I
don't think its worth keeping `NoAutoHelp` around for it.
2022-06-08 12:02:13 -05:00
Ed Page
dffd7932b3 fix(assert): Check for version if user specifies ArgAction::Version 2022-06-08 11:59:49 -05:00
Ed Page
912a629070
Merge pull request #3799 from epage/value
fix(derive): Clarify ArgEnum as ValueEnum
2022-06-08 11:27:47 -05:00
Ed Page
9e38353442 fix(derive): Clarify ArgEnum as ValueEnum
We aren't enumerating arguments but values for an argument, so the name
should reflect that.

This will be important as part of #1807 when we have more specific
attribute names.
2022-06-08 11:14:09 -05:00
Ed Page
0377051353
Merge pull request #3798 from epage/docs
docs(tutorial): Update for new API
2022-06-08 10:57:03 -05:00
Ed Page
8dde489e3a docs(tutorial): Update for new API 2022-06-08 10:35:06 -05:00
Ed Page
3ded927662
Merge pull request #3797 from epage/deprecate
fix: Deprecate features redundant with Actions
2022-06-08 10:25:11 -05:00
Ed Page
11d93141dd test(derive): Update snapshots 2022-06-08 09:56:57 -05:00
Ed Page
14a62e11fd fix(parser): Deprecate multiple_occurrences
Fixes #3772
2022-06-08 09:54:23 -05:00
Ed Page
b78a0e6ccd style: Make clippy happy 2022-06-08 09:34:20 -05:00
Ed Page
1abc945545 fix(parser): Process overrides with new Actions 2022-06-08 08:59:43 -05:00
Ed Page
55a705c447 test: Ensure we don't break compatibility 2022-06-07 16:21:37 -05:00
Ed Page
4a9c4dee64 refactor(test): Make it easier to fork tests 2022-06-07 16:21:12 -05:00
Ed Page
19d8ca807f fix(derive): Transition off of multiple_occurrences
For programs opting into the clap v4 behavior (with `action` or
`value_parser` attributes), we'll no longer generate a
`multiple_occurrences(true)` call in preparation for deprecating
`multiple_occurrences`.  See #3772.
2022-06-07 15:38:14 -05:00
Ed Page
efc1520223 perf(derive): Cache positional status 2022-06-07 15:05:11 -05:00
Ed Page
7980c5ceb8 fix(parser): Force multiple occurrences with new Actions
This is needed for deprecate `multiple_occurrences`
2022-06-07 14:34:54 -05:00
Ed Page
d88ca13730 docs: Reflect the dropping of occurrences_of 2022-06-07 14:09:08 -05:00