backport __fish_seen_argument.

This commit is contained in:
Tim Reddehase 2018-09-25 15:56:37 +02:00 committed by David Gillies
parent 9ecb79d309
commit 2035fda4de
No known key found for this signature in database
GPG key ID: BD350530941BDC96
2 changed files with 23 additions and 0 deletions

View file

@ -39,6 +39,28 @@ function __fish_%s_seen_subcommand_path --description 'Test whether the full pat
set -e cmd[1]
return (test (string trim -- "$argv") = (string trim -- "$cmd"))
end
# borrowed from current fish-shell master, since it is not in current 2.7.1 release
function __fish_seen_argument
argparse 's/short=+' 'l/long=+' -- $argv
set cmd (commandline -co)
set -e cmd[1]
for t in $cmd
for s in $_flag_s
if string match -qr "^-[A-z0-9]*"$s"[A-z0-9]*\$" -- $t
return 0
end
end
for l in $_flag_l
if string match -q -- "--$l" $t
return 0
end
end
end
return 1
end
`, cmd.Name(), cmd.Name(), strings.Join(subCommandNames, " "), cmd.Name()))
}

View file

@ -88,6 +88,7 @@ func TestFishCompletions(t *testing.T) {
// check for preamble helper functions
check(t, output, "__fish_root_no_subcommand")
check(t, output, "__fish_root_seen_subcommand_path")
check(t, output, "__fish_seen_argument")
// check for subcommands
check(t, output, "-a echo")