Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Deprecate features redundant with Actions #3797

merged 17 commits into from Jun 8, 2022


Copy link

@epage epage commented Jun 8, 2022

This includes

  • ArgAction::StoreValue for ArgAction::Set and ArgAction::Append
  • ArgAction::IncOccurrences for ArgAction::SetTrue and ArgAction::Count
  • Argn::max_occurrences for value_parser!(u64).range(..N) for ArgAction::Count
  • Command::args_override_self in favor of ArgAction::Set
  • ArgMatches::occurrences_of in favor of ArgAction::Count and ArgMatches::value_source
  • Arg::multiple_occurrences in favor of Arg::multiple_values (positional), ArgAction::Append (flag with value), or ArgAction::Count (flag without value)

To help make this a reality

  • We added u64 range ValueParser for replacing Arg::max_occurrences
  • Automatically opt-in to multiple_occurrences with new actions (for non-positional)
  • Fixed new actions to process overrides
  • Updated derive to not use multiple_occurrences
  • Duplicated builder tests for old / new way of doing things to make sure new features work while old don't break compatibility
    • It'll be a slow process to update all of the tests for the new functionality

epage added 17 commits June 6, 2022 12:21
Dropping these will help simplify a lot, including removing of

These come at the cost of the derive not yet supporting types that impl
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
clap-rs#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

See also clap-rs#3795
This mostly exist for
- Knowing of the value came from the command-line but we now have
- Counting the number of flags but we now have `ArgAction::Count`
This is needed for deprecate `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 clap-rs#3772.
@epage epage merged commit 3ded927 into clap-rs:master Jun 8, 2022
20 checks passed
@epage epage deleted the deprecate branch June 8, 2022 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

1 participant