Open jhesqqq opened 4 months ago
Renamed the title to focus on the problem, rather than solution.
I know this has been discussed before but not finding the Issues or Discussions for it. #1210 is either similar or the same thing, depending on your perspective.
There are several problems to solve
short
from accepting &str
to char
to better represent this limitation in type systemIf this is more like #1210, then #2468 is likely the way forward.
I noticed that in v2, clap short allowed multiple characters, but only the first one was retrieved.
For example, short("abc")
appears as -a on the command line.
API: With clap v3, we intentionally switched
short
from accepting&str
tochar
to better represent this limitation in type system
I think developing a way to regulate whether or not composition behavior is used is a very important feature for developers and users. The right sacrifice can sometimes be a big help.
Behavior: we have to deal with people who want true shorts with combining of multiple flags + a value with people who want multi-character shorts. There might even people who want both.
- If its both, that adds its own complexities.
- If its either, then we have to balance the scope of how much this is needed vs the compile time and binary size of making this large of a behavior swap conditional
I am aware of these issues and hope such issues can be resolved.
If this is more like https://github.com/clap-rs/clap/issues/1210, then https://github.com/clap-rs/clap/issues/2468 is likely the way forward.
Finally, I wish clap better and better!
Please complete the following tasks
Clap Version
4.5.1
Describe your use case
Let
short
flag allow more characters than one to facilitate user input.I know that short flags implement their combined behavior by default in clap, which prevents
short
flags from using more than two characters. For example,ls -l-a = ls -la
, which I think is a great feature.However, implementing only this functionality ignores the case where the user does not want to enter the
long
flag if there are too many parameters. For example, the user wants to typexxx-oJ
instead ofxxx --oJ
Describe the solution you'd like
I have a solution, which is that clap can open a method to control whether I want this default composition behavior or not.
When I turn off the composition behavior, the
short
flag length is at least 1 or greater. For example,-oJ
, the output is json, there is no combined behavior here, just a single instance.When I enable the composition behavior (which is the default), the
short
flag is limited to a length of 1. Which is now the composition behavior.Alternatives, if applicable
No response
Additional Context
No response