Replies: 2 comments 2 replies
-
The quick summary:
I'm surprised you didn't see
Huh, for some reason a
Yes, this was expected. Before whether an
imo A deprecation should only be given if its actionable which means the alternative can be implemented. While a lot of changes from v3 to v4 were able to be handled that way (like
When writing that, I made the assumption that people would read the documentation for contains_id and SetTrue which explain the use cases, provide caveats, and include examples.
The second item listed in the
Huh, looks like we forgot to update everything to |
Beta Was this translation helpful? Give feedback.
-
Thank you for the clarifications. I've found another migration obstacle: |
Beta Was this translation helpful? Give feedback.
-
I'm finding it difficult and laborious to upgrade from clap v3 to v4. I've tried
deprecated
feature flag, but it was not enough, as behavior of flags has changed substantially, and the deprecation notice does not fully explain the change.Problem 1: I expected the repository to have something like
(I've meantCHANGES.md
UPGRADING.md
) orMIGRATION_GUIDE.md
, but there isn't and the README doesn't mention upgrading. The best source of this info I can tell is old release notes of early v4 releases, but that's on page 4 of GitHub releases list, and I'm not sure if this information is up to date (could have changed in later versions).Problem 2: In v4 all flag options started defaulting to taking a value:
became
--quiet <quiet>
. Is that expected? I've had to add.num_args(0)
to all my flags, but I'm not sure if this is the correct way to define a simple flag (I don't wantyes/no
arguments, repetition counters or anything fancy, just check presence).Problem 2a: the
.takes_value()
and.min_values()
functions lack#[deprecated]
in v3, so they broke in v4, despite v3 compiling without warnings. It could have been a good place to warn about everything defaulting to taking a value.Problem 3: The deprecation notice for
is_present
mentions there'scontains_id
andArgAction
, but does not really explain how to use them, and I couldn't find a definitive answer how to use the flags in v4. The examples folder covers advanced uses with subcommands and parsers, but I haven't noticed a basic example for the most basic boolean flag done correctly.I've changed
is_present
tocontains_id
, because it seemed simpler and the deprecation notice did not explain how to readArgAction::SetTrue
once it's set. It still worked as expected v3 without warnings, but in v4 started always returning true. I've added.action(ArgAction::SetTrue)
too, andcontains_id
still always returned true.The documentation for
contains_id
mentionsvalue_source
, which has this example:but I'm not sure if that's really the right way to replace
is_present
. It seems long and indirect way to approach the problem (I just want a boolean, not a source where it came from).Docs for
ArgAction::SetTrue
useget_one::<bool>()
, which at first glance sounded like a perfect logical replacement foris_present
that fits with the other getters …but the problem is that it returnsOption<&bool>
, which is awkward to use. It requiresmatches.contains_id("quiet").copied().unwrap_or(false)
.So I feel like I'm missing something obvious, and following the trail of
contains_id
andArgAction
docs has led me to weird solutions. Has this:really become:
Beta Was this translation helpful? Give feedback.
All reactions