Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I decided to use cargo-deny as a test case for upgrading to clap 3.2 which was just released (release announcement forthcoming).
For derive users, there isn't too much different. By specifying a default
#[clap(action)]
or#[clap(value_parser)]
attribute, you opt-in to the new behavior that will be the default in clap 4.0. The main difference is instead of theparse
attribute that is unique to the derive, you now have thevalue_parser
attribute which comes fromArg::value_parser
. When novalue_parser
is specified, we'll default tovalue_parser!(T)
which will auto-select an appropriate value parser for the given field's core type. In practice, this means the defaultvalue_parser
forPathBuf
is now safe to use.We also renamed
ArgEnum
toValueEnum
to make the name more meaningful and for some future work we'll be doing.value_parser
mostly gets rid of the need forvalue_enum
attribute except for when dealing with defaults, so I just left the attribute in place. I went ahead and switched some enums that were almostValueEnum
to beingValueEnum
.