mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 22:21:15 -03:00
fix argparse handling of short flag only specs
@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
This commit is contained in:
@@ -86,15 +86,42 @@ set -l
|
||||
for v in (set -l -n); set -e $v; end
|
||||
argparse 'v/verbose' '#-val' 't/token=' -- -123 a1 --token woohoo --234 -v a2 --verbose
|
||||
set -l
|
||||
|
||||
echo '# Should be set to 987'
|
||||
for v in (set -l -n); set -e $v; end
|
||||
argparse 'm#max' -- argle -987 bargle
|
||||
set -l
|
||||
|
||||
echo '# Should be set to 765'
|
||||
for v in (set -l -n); set -e $v; end
|
||||
argparse 'm#max' -- argle -987 bargle --max 765
|
||||
set -l
|
||||
|
||||
echo '# Bool short flag only'
|
||||
for v in (set -l -n); set -e $v; end
|
||||
argparse 'C' 'v' -- -C -v arg1 -v arg2
|
||||
set -l
|
||||
|
||||
echo '# Value taking short flag only'
|
||||
for v in (set -l -n); set -e $v; end
|
||||
argparse 'x=' 'v/verbose' -- --verbose arg1 -v -x arg2
|
||||
set -l
|
||||
|
||||
echo '# Implicit int short flag only'
|
||||
for v in (set -l -n); set -e $v; end
|
||||
argparse 'x#' 'v/verbose' -- -v -v argle -v -x 321 bargle
|
||||
set -l
|
||||
|
||||
echo '# Implicit int short flag only with custom validation passes'
|
||||
for v in (set -l -n); set -e $v; end
|
||||
argparse 'x#!_validate_int --max 500' 'v/verbose' -- -v -v -x 499 -v
|
||||
set -l
|
||||
|
||||
echo '# Implicit int short flag only with custom validation fails' >&2
|
||||
for v in (set -l -n); set -e $v; end
|
||||
argparse 'x#!_validate_int --min 500' 'v/verbose' -- -v -v -x 499 -v
|
||||
set -l
|
||||
|
||||
##########
|
||||
# Verify that flag value validation works.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user