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
.action(ArgAction::Help)
and ArgAction::Version
bypass exclusive(true)
#4046
Comments
.action(ArgAction::Help)
and ArgAction::Version
bypass .action(ArgAction::Help)
and ArgAction::Version
bypass exclusive(true)
It looks like you are taking manually implemented help and version flags and switching them to actions. Could you expand on why those flags need to be exclusive? |
It's a weird behaviour of the GNU true and false utils. So a command like this
would show the version, but
wouldn't. I believe the rationale is to maintain as much compatibility as possible with versions of the We can work around this, but it was surprising to see the option being ignored when the |
ArgActions are specified in the documentation for how to react when evaluating an argument, as in they are immediately processed. An important aspect of this is that we want to make actions pluggable and would like toe avoid special casing as that is something the user can't replicate.
Considering the defined behavior of ArgAction, what seems like a relatively small use case (not even the described use case can rely on what is being requested, still small if it did), and the fact that its possible to workaround it, I'm going to go ahead and close this as part of our effort to limit the scope of clap to help keep binary sizes and compile times down |
Alright, we will work around it by checking the number of arguments. ArgAction being processed immediately seems counterintuitive, but I can see how it makes sense for counting etc.. Thank you! I think the linked PR can then also be closed. @jarkonik Thank you for putting in the effort to implement this! |
Please complete the following tasks
Rust Version
rustc 1.62.1 (e092d0b6b 2022-07-16)
Clap Version
master
Minimal reproducible code
Steps to reproduce the bug with the above code
cargo run
Actual Behaviour
When using
.action(ArgAction::Help)
or.action(ArgAction::Version)
and setting.exclusive(true)
on one of them and when input contains both flags the returned error isDisplayError
orDisplayVersion
.Expected Behaviour
When using
.action(ArgAction::Help)
or.action(ArgAction::Version)
and setting.exclusive(true)
on one of them and when input contains both flags it seems intuitive for the error to beArgumentConflict
Additional Context
Would enable implementing
false
andtrue
coreutils commands (uutils/coreutils#3784) usingArgAction::Version
andArgAction::Help
Debug Output
No response
The text was updated successfully, but these errors were encountered: