mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
change show
test utility function
Due to how various tests show the status of variables I decided to modify the `show` test utility function I recently added.
This commit is contained in:
parent
8f548962b7
commit
dc33c1afe1
5 changed files with 18 additions and 25 deletions
|
@ -59,28 +59,24 @@ echo '# One arg and no matching flags'
|
|||
begin
|
||||
argparse h/help -- help
|
||||
set -l
|
||||
show $argv
|
||||
end
|
||||
|
||||
echo '# Five args with two matching a flag'
|
||||
begin
|
||||
argparse h/help -- help --help me -h 'a lot more'
|
||||
set -l
|
||||
show $argv
|
||||
end
|
||||
|
||||
echo '# Required, optional, and multiple flags'
|
||||
begin
|
||||
argparse 'h/help' 'a/abc=' 'd/def=?' 'g/ghk=+' -- help --help me --ghk=g1 --abc=ABC --ghk g2 --d -g g3
|
||||
set -l
|
||||
show $argv
|
||||
end
|
||||
|
||||
echo '# --stop-nonopt works'
|
||||
begin
|
||||
argparse --stop-nonopt 'h/help' 'a/abc=' -- -a A1 -h --abc A2 non-opt 'second non-opt' --help
|
||||
set -l
|
||||
show $argv
|
||||
end
|
||||
|
||||
echo '# Implicit int flags work'
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
# No args
|
||||
# One arg and no matching flags
|
||||
argv help
|
||||
count=1
|
||||
|help|
|
||||
# Five args with two matching a flag
|
||||
_flag_h 2
|
||||
_flag_help 2
|
||||
argv 'help' 'me' 'a lot more'
|
||||
count=3
|
||||
|help|
|
||||
|me|
|
||||
|a lot more|
|
||||
# Required, optional, and multiple flags
|
||||
_flag_a ABC
|
||||
_flag_abc ABC
|
||||
|
@ -21,19 +15,12 @@ _flag_ghk 'g1' 'g2' 'g3'
|
|||
_flag_h 1
|
||||
_flag_help 1
|
||||
argv 'help' 'me'
|
||||
count=2
|
||||
|help|
|
||||
|me|
|
||||
# --stop-nonopt works
|
||||
_flag_a A2
|
||||
_flag_abc A2
|
||||
_flag_h 1
|
||||
_flag_help 1
|
||||
argv 'non-opt' 'second non-opt' '--help'
|
||||
count=3
|
||||
|non-opt|
|
||||
|second non-opt|
|
||||
|--help|
|
||||
# Implicit int flags work
|
||||
_flag_val 123
|
||||
argv 'abc' 'def'
|
||||
|
|
|
@ -193,4 +193,4 @@ if test (string length "$x") -ne $FISH_READ_BYTE_LIMIT
|
|||
end
|
||||
|
||||
echo '# Confirm reading non-interactively works (#4206 regression)'
|
||||
echo abc\ndef | ../test/root/bin/fish -i -c 'read a; read b; show $a; show $b'
|
||||
echo abc\ndef | ../test/root/bin/fish -i -c 'read a; read b; show a; show b'
|
||||
|
|
|
@ -59,7 +59,7 @@ newline
|
|||
# chunked read tests
|
||||
Chunked reads test pass
|
||||
# Confirm reading non-interactively works (#4206 regression)
|
||||
count=1
|
||||
|abc|
|
||||
count=1
|
||||
|def|
|
||||
$a count=1
|
||||
$a[1]=|abc|
|
||||
$b count=1
|
||||
$b[1]=|def|
|
||||
|
|
|
@ -1,4 +1,14 @@
|
|||
function show
|
||||
echo count=(count $argv)
|
||||
printf '|%s|\n' $argv
|
||||
# Show information about the named var(s) passed to us.
|
||||
function show --no-scope-shadowing
|
||||
for v in $argv
|
||||
if set -q $v
|
||||
set -l c (count $$v)
|
||||
printf '$%s count=%d\n' $v $c
|
||||
for i in (seq $c)
|
||||
printf '$%s[%d]=|%s|\n' $v $i $$v[1][$i]
|
||||
end
|
||||
else
|
||||
echo \$$v is not set
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue