mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-01 21:21:15 -03:00
Added support to fish_opt for defining a long flag with no short flag.
Specifically, this now makes the -s/--short option to fish_opt optional when the -l/--long option is given. This commit does not modify argparse, as it already supports defining long flags without a corresponding short flag, however fish_opt would never take advantage of this feature. Note that due to a limitation in argparse, fish_opt will give an error if you try to define a one-character --long flag without also providing a --short option. For backwards compatibility, the --long-only flag is still included with fish_opt, and when used with -s/--short, will behave as before (the short flag is still defined, but argparse will fail if it is actually used by the parsed arguments, moreover the _flag_ option variables will not be defined). This can however be used to define a one character long flag.
This commit is contained in:
@@ -136,9 +136,11 @@ Option Specifications
|
||||
|
||||
Each option specification consists of:
|
||||
|
||||
- An optional alphanumeric short flag character, followed by a ``/`` if the short flag can be used by someone invoking your command or, for backwards compatibility, a ``-`` if it should not be exposed as a valid short flag (in which case it will also not be exposed as a flag variable).
|
||||
- An optional alphanumeric short flag character.
|
||||
|
||||
- An optional long flag name, which if not present the short flag can be used, and if that is also not present, an error is reported
|
||||
- An optional long flag name, seperated from the short flag (if present) by a ``/``. If neither a short flag nor long flag are present, an error is reported.
|
||||
|
||||
- For backwards compatibility, if there is a short and a long flag, a ``-`` can be used in place of the ``/``, if the short flag is not to be usable by users (in which case it will also not be exposed as a flag variable).
|
||||
|
||||
- Nothing if the flag is a boolean that takes no argument or is an integer flag, or
|
||||
|
||||
|
||||
Reference in New Issue
Block a user