Closed BenWiederhake closed 4 months ago
-ez foo bar
takes the z
as the argument and assumes that an attached value and unattached values are not mixed, and stops parsing -e
.
Without other context, this feels niche enough that it wouldn't make sense to move forward on. As a user, I would be confused to see -ez foo bar
and for that to be parsed the same as -ze foo bar
. This would be complicated to implement, deferring the evaluation of short arguments while processing other arguments, which comes at the cost of binary size and compile times for all users who don't want this behavior. This would also has a cost in contributing to API bloat. Every new knob we add makes it harder to find every other knob that exists, including what we just added. The more we add, the less likely people will use any of it.
Turns out, I wanted a boolean flag all along, and clap easily supports it. Sorry for the noise, and thanks for the quick response!
Please complete the following tasks
Rust Version
rustc 1.76.0 (07dca489a 2024-02-04)
Clap Version
4.5.1
Minimal reproducible code
Steps to reproduce the bug with the above code
The above code demonstrates several test cases. Among them is the problematic case
-ez foo bar
, wherez
is supposed to be interpreted as the noarg flag--zero-terminated
. Note that behavior like this is sometimes desirable, e.g. when emulating GNU shuf:Actual Behaviour
Clap interprets the
z
in-ez foo bar
as the sole argument to-e
, as if there was a call tovalue_delimiter
. clap then errors, and refuses to understand thefoo bar
part of the command.Expected Behaviour
Clap should (provide a switch to enable a mode in order to) prefer short-arg expansion over argument-taking. In other words, I want
-ez foo bar
to be interpreted as the two separate concepts--echo foo bar
and--zero-terminated
.Additional Context
I understand that this might be considered a breaking change. I can see at least two ways to go about this:
Command
-level, i.e.Command::single_dash_is_always_train_of_short_args(true)
or something like that, so that all agglomerations of short flags are switched here.Arg
-level, i.e.Arg::permit_direct_short_arg(false)
or something like that, so that-eARG
is not even considered.I admit that this may not be a "bug" in the "crash" sense, but it's definitely an incompatibility of existing features.
Debug Output
No response
Similar but different issues:
1125: This bug does not involve required arguments
5115: This bug does not involve positional arguments