Closed nihaals closed 3 months ago
I believe this is another variant of #4697. There are ... issues when relying on the behavior of nested groups.
In both cases, when an argument is set, we also set the group. However, that isn't recursive up the chain and so when the top-level group checks the status of its direct members, it gets incomplete information.
Closing in favor of #4697 though we should not this variant of the symptom.
If there is a reason we should keep this open separately, let us know!
Please complete the following tasks
Rust Version
rustc 1.77.1 (7cf61ebde 2024-03-27)
Clap Version
4.5.4
Minimal reproducible code
Steps to reproduce the bug with the above code
cargo run -- test --help
cargo run -- test
cargo run -- test --all
cargo run -- test --foo --bar
cargo run -- test --all --foo
Actual Behaviour
Expected Behaviour
Passing in
--all
should satisfy the requirement and it shouldn't show an empty list of required arguments.Additional Context
The goal is to either require an individual item or
--all
. Sotest
fails,test --all
andtest --foo --bar
works andtest --all --foo
fails.This is possible by avoiding
flatten
and using conflicts instead:I couldn't figure out a way to use conflicts as a workaround with
flatten
if the group is still required.Also an extra question, I'm unsure if this is the best way to have a flag that essentially sets the values of a set of other flags (without checking if
all
is true and then mutatingfoo
andbar
to true/always checking iffoo
orall
is true). It seems like setting a customaction
wouldn't help here (to setfoo
andbar
to true) but maybe there's a better way of setting up the flags here that avoids this issue.Debug Output