mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-30 14:24:35 +08:00
f3130ce70b
@faho noticed that option specs which don't have a long flag name are not handled correctly. This fixes that and adds unit tests. Fixes #4232
40 lines
1.6 KiB
Plaintext
40 lines
1.6 KiB
Plaintext
# No args is an error
|
|
argparse: No option specs were provided
|
|
# Missing -- is an error
|
|
argparse: Missing -- separator
|
|
# Flags but no option specs is an error
|
|
argparse: No option specs were provided
|
|
# Invalid option specs
|
|
argparse: Invalid option spec 'h-' at char '-'
|
|
argparse: Short flag '+' invalid, must be alphanum or '#'
|
|
argparse: Invalid option spec 'h/help:' at char ':'
|
|
argparse: Invalid option spec 'h-help::' at char ':'
|
|
argparse: Invalid option spec 'h-help=x' at char 'x'
|
|
# --max-args and --min-args work
|
|
min-max: Expected at least 1 args, got only 0
|
|
min-max: Expected at most 3 args, got 4
|
|
min-max: Expected at most 1 args, got 2
|
|
# Invalid "#-val" spec
|
|
argparse: Implicit int short flag '#' does not allow modifiers like '='
|
|
# Invalid arg in the face of a "#-val" spec
|
|
argparse: Unknown option '-x'
|
|
Standard input (line 38):
|
|
argparse '#-val' -- abc -x def
|
|
^
|
|
# Defining a short flag more than once
|
|
argparse: Short flag 's' already defined
|
|
# Defining a long flag more than once
|
|
argparse: Long flag 'short' already defined
|
|
# Defining an implicit int flag more than once
|
|
argparse: Implicit int flag '#' already defined
|
|
# Defining an implicit int flag with modifiers
|
|
argparse: Implicit int short flag 'v' does not allow modifiers like '='
|
|
# Implicit int short flag only with custom validation fails
|
|
argparse: Value '499' for flag 'x' less than min allowed of '500'
|
|
# Implicit int flag validation fails
|
|
argparse: Value '765x' for flag 'max' is not an integer
|
|
argparse: Value 'a1' for flag 'm' is not an integer
|
|
# Explicit int flag validation
|
|
argparse: Value '2' for flag 'm' greater than max allowed of '1'
|
|
argparse: Value '-1' for flag 'max' less than min allowed of '0'
|