-
Notifications
You must be signed in to change notification settings - Fork 21
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
short args should be parsed when there is no space after #7
Comments
How would you distinguish between this and the other kind of short args that can be chained together, e.g. |
In the OP example |
It's a good question. I looked at two standard programs that do similar things. On the other hand,
So I guess what |
In tar you can give |
|
Sorry I think I misunderstood your point. A space should be allowed, but at least when the flag is on its own it should be optional. |
What I wanted to demonstrate is that we could accept also combined short-options which accept itself arguments. For example the args |
With most programs, the f would have to be after the z.
…On Tue, Feb 14, 2023, 5:52 AM Tobias Roeser ***@***.***> wrote:
What I wanted to demonstrate is that we could accept also combined
short-options which accept itself arguments. For example the args -x -f
<file> -z could also be given as -xfz <file>.
—
Reply to this email directly, view it on GitHub
<#7 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAYAUAL6TACBAEZUL6B6GTWXNPVZANCNFSM4YCRGN3A>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Fixes #7 This PR allows flags like `-abtrue` to mean `-a -b true`, by walking the combined flag one character at a time and seeing if each character is a flag that takes zero values, or a non-flag argument that takes one value, which is set to the remaining part of the combined flag (in the case above, `"true"`). This allows some nice shorthands, like `./mill -wk -j10` rather than `./mill -w -k -j 10` This is the only way I could find that allows both combining multiple flags like `-ab`, and combining flags with values like `-btrue`. Trying to handle more sophisticated cases like `tar tfv <file>` where `f` is given `<file>` is fundamentally incompatible, and would need some user-facing configuration to enable. Combining multiple short arguments together with gflags `=` syntax, e.g. `-ab=true`, is currently not allowed. This follows the current limitation where we do not allow single short args to be used with `=`, e.g. `-f=bar` is prohibited. In general, combined short arguments are not allowed to have `=` in it. If you want the `=` to be part of the value, you can move it into a separate token e.g. `-ab =true` For now, this improvement can be done fully transparently and backwards-compatibly without any need for user opt-in or configuration, and should cover the 99% use case. There is no conflict with existing long arguments, as those currently require two dashes `--`, and so a multi-character token starting with a single `-` is currently disallowed. Adding additional flexibility and configuration can come later future Covered by additional unit tests
for example
should allow
-j16
as-j 16
.currently
-j16
goes to leftoverThe text was updated successfully, but these errors were encountered: