Feature Request: Override setting for groups #1023
Labels
A-builder
Area: Builder API
A-validators
Area: ArgMatches validation logi
C-enhancement
Category: Raise on the bar on expectations
E-medium
Call for participation: Experience needed to fix: Medium / intermediate
There are many instances of command line utilities that have groups of flags, all able to override each other.
For example, as mentioned in this issue, the
od
utility has 10 flags that all override each other:abcdfilosx
. The last appearing flag is the one that is used. Likewise, thels
utility has similar "groups" of overriding flags: ls manualIf this feature existed, one could input it into clap like this:
This is technically already do-able; just set every individual argument to overload every other argument. However, that's inefficient, unreasonably difficult to input, and grows faster than exponentially.
The proposed feature would be one new function:
ArgGroup::override_with_self(value: bool) -> Self
.Implementation for just flags would imply
Arg::multiple(true)
for its args and then simply forceArgMatches::value_of
to return the last parsed value. It may be more complicated to account for arguments with values (--foo bar
)? I'm not familiar with the internal workings of clap-rs, so I don't know how difficult it would be to add this feature.This feature would be very useful when re-writing old command-line apps, as this kind of group-override pattern shows up a lot.
The text was updated successfully, but these errors were encountered: