mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-30 14:53:11 +00:00
e20c08d04e
This read something like `o=!_validate_int`, and the flag modifier reading kept the pointer after the `!`, so it created a long flag called `_validate_int`, which meant it would not only error out form ```fish argparse 'i=!_validate_int' 'o=!_validate_int' -- $argv ``` with "Long flag '_validate_int' already defined", but also set $_flag_validate_int. Fixes #5864.
128 lines
3.1 KiB
Text
128 lines
3.1 KiB
Text
|
|
####################
|
|
# 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 41):
|
|
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 '='
|
|
|
|
####################
|
|
# No args
|
|
|
|
####################
|
|
# One arg and no matching flags
|
|
|
|
####################
|
|
# Five args with two matching a flag
|
|
|
|
####################
|
|
# Required, optional, and multiple flags
|
|
|
|
####################
|
|
# --stop-nonopt works
|
|
|
|
####################
|
|
# Implicit int flags work
|
|
|
|
####################
|
|
# Should be set to 987
|
|
|
|
####################
|
|
# Should be set to 765
|
|
|
|
####################
|
|
# Bool short flag only
|
|
|
|
####################
|
|
# Value taking short flag only
|
|
|
|
####################
|
|
# Implicit int short flag only
|
|
|
|
####################
|
|
# Implicit int short flag only with custom validation passes
|
|
|
|
####################
|
|
# 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
|
|
|
|
####################
|
|
# Check the exit status from argparse validation
|
|
|
|
####################
|
|
# 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'
|
|
|
|
####################
|
|
# Errors use function name by default
|
|
notargparse: Unknown option '--banana'
|
|
Standard input (line 353):
|
|
argparse a/alpha -- --banana
|
|
^
|
|
in function 'notargparse'
|
|
|
|
####################
|
|
# Ignoring unknown options
|
|
|
|
####################
|
|
# Check for crash when last option is unknown
|
|
|
|
####################
|
|
# Checking arguments after --
|
|
|
|
####################
|
|
# Checking validation for short flags only
|
|
argparse: Value 'banana' for flag 'o' is not an integer
|
|
argparse: Value '-o' for flag 'i' is not an integer
|