Commit graph

5898 commits

Author SHA1 Message Date
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
Ed Page
86a162d1bb fix(parser): Deprecate occurrences_of
This mostly exist for
- Knowing of the value came from the command-line but we now have
  `ArgMatches::source`
- Counting the number of flags but we now have `ArgAction::Count`
2022-06-07 13:30:32 -05:00
Ed Page
f0cc8b8d25 test: Improve failure output 2022-06-07 13:20:25 -05:00
Ed Page
1428785677 fix(parser): Deprecate args_override_self
This shouldn't be needed anymore now that this is effectively the new
behavior for the non-deprecated actions.

This was briefly talked about in
https://github.com/clap-rs/clap/discussions/2627 but I wasn't familiar
enough with the implementation to know how safe it is.  Now, maintainrs
and users can be more confident because they are explicitly opting into
it.

See also #3795
2022-06-06 14:57:24 -05:00
Ed Page
a979cf9bb8 fix(parser): Deprecate max_occurrences 2022-06-06 14:09:24 -05:00
Ed Page
0ba63664fe feat(builder): Offer u64 ranges 2022-06-06 14:02:01 -05:00
Ed Page
1879826b21 fix(parser): Deprecate StoreValue / IncOccurrences Actions
Dropping these will help simplify a lot, including removing of
occurrences.

These come at the cost of the derive not yet supporting types that impl
`From`.
2022-06-06 13:41:27 -05:00
Ed Page
4a694f3592 refactor(parser): Be explicit in checking present values 2022-06-06 12:21:47 -05:00
Ed Page
805cce74c6
Merge pull request #3794 from epage/derive
feat(derive): Expose control over Actions
2022-06-06 12:07:34 -05:00
Ed Page
647896d929 feat(derive): Expose control over Actions
This is the derive support for #3774 (see also #3775, #3777)

This combined with `value_parser` replaces `parser`.  The main
frustration with this is that `ArgAction::Count` (the replacement for
`parse(from_occurrences)` must be a `u64`.  We could come up with a
magic attribute that is meant to be the value parser's parsed type.  We
could then use `TryFrom` to convert the parsed type to the user's type
to allow more.  That is an exercise for the future.  Alternatively, we
have #3792.

Prep for this included
- #3782
- #3783
- #3786
- #3789
- #3793
2022-06-06 11:35:07 -05:00
Ed Page
955f8b627a
Merge pull request #3793 from epage/required
fix(validator): Ignore defaults for requireds
2022-06-06 11:32:07 -05:00
Ed Page
4489f09f10 feat(parser): Allow querying whether actions take values 2022-06-06 11:20:08 -05:00
Ed Page
0f1de7303d fix(validator): Ignore defaults for requireds
This is a follow up to #3420.  Its easy to overlook this because it is only
useful for the conditionals (we actually prevent applying unconditional
defaults to unconditional requireds).  This became apparent with the
increased use of defaults with `SetTrue`.

As always, there is the question of when is a bug fix a breaking change.
I'm going to consider this safe since we prevent some instances of this
from even happening and we already did #3420 and this is in line with
those.
2022-06-06 11:07:04 -05:00
Ed Page
ac64391910 refactor(parser): Remove dead code 2022-06-06 10:15:28 -05:00
Ed Page
44e1095166
Merge pull request #3789 from epage/refactor
refactor: Prep for actions in derive
2022-06-04 13:46:39 -05:00
Ed Page
002204a122 test(derive): Update ui tests 2022-06-04 13:24:46 -05:00
Ed Page
9638f33d2f fix(parser): Exclusive shouldnt preclude defaults
Unsure why a comment said this doesn't matter.  It matters both for
counting arguments and for reporting the correct argument is exclusive.
2022-06-04 12:58:53 -05:00
Ed Page
f3bc3d5eb7 fix(error): Don't include default-but-required arguments in usage 2022-06-04 12:58:53 -05:00
Ed Page
a971346004 test(parser): Verify indices of defaults
I thought I had broken this but it always seemed to have worked this way
2022-06-04 12:58:53 -05:00
Ed Page
5f56e93c0f refactor(parser): Clarify we are working with ids, not names 2022-06-04 12:58:53 -05:00
Ed Page
ccd6663de9 fix(help): Output some bool possible values
Originally I hid all, assuming the flag-only use case but we had to
prevent that from showing up anyways.  For the takes_value case, we
should be showing something since we know what it accepts.  I decided to
only show the most basic values and hide the rest so as to not overwhelm
the user with redundant options and hope the user recognizes they are
redundant.
2022-06-04 12:58:53 -05:00
Ed Page
b09def1ad0 test(derive): Verify doc comments on ArgEnum 2022-06-04 12:58:53 -05:00
Ed Page
a3092bafce fix(help): Don't report flag defaults
Now that flags can have meaningful defaults and with defaults being
implicitly set for certain actions, they appear in help but don't quite
make sense.
2022-06-04 12:58:53 -05:00
Ed Page
11fbe7e54b test(derive): Improve help output assertions 2022-06-04 12:58:53 -05:00
Ed Page
52e2874c03 fix(builder): Make it easier to discover/access ArgAction 2022-06-04 12:58:53 -05:00
Ed Page
d56d8dd59e chore: Make it easy to reproduce CI docs run 2022-06-04 12:58:53 -05:00
Ed Page
844dbae96b
Merge pull request #3787 from epage/bench
refactor(bench): Pull out benchmarks into own crate
2022-06-03 14:09:20 -05:00