You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow short arguments and flags to be combined (#102)
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
0 commit comments