From 37f4cbe3d7af077cd733a96529952814b506d82e Mon Sep 17 00:00:00 2001 From: Dan Underwood Date: Sun, 27 Sep 2015 19:48:12 +0100 Subject: [PATCH] Fix of multiple synonyms for apm command `__fish_apm_using_command` was incorrectly taking lists of commands, new function added to support multiple a command having synonyms. Simplify switch statement Also remove superfluous function. Allow for multiple completions after a command Useful for removing packages, will complete for more than one. Code improvements --- share/completions/apm.fish | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/share/completions/apm.fish b/share/completions/apm.fish index 9a206c53d..6b80a1b81 100644 --- a/share/completions/apm.fish +++ b/share/completions/apm.fish @@ -18,21 +18,17 @@ function __fish_apm_needs_command return 1 end -# Returns exit code of 0 if a command (argv[1]) appears once, exclusions can -# can be provided (argv[2..-1]) that are ignored, e.g. `get` and `set` +# Returns exit code of 0 if any command (argv[1..-1]) appears once, ignores flags. function __fish_apm_using_command - set command $argv[1] - if test (count $argv) -gt 1 - set exclusions $argv[2..-1] - end + set commands $argv set cmd (commandline -opc) if test (count $cmd) -gt 1 set -l command_seen_once 1 for c in $cmd[2..-1] switch $c - case '--color' '--no-color' $exclusions + case '-*' continue - case $argv + case $commands # If the command is seen more than once then return 1 if test $command_seen_once -eq 1 set command_seen_once 0 @@ -40,7 +36,11 @@ function __fish_apm_using_command return 1 end case '*' - return 1 + if test $command_seen_once -eq 0 + return 0 + else + return 1 + end end end return $command_seen_once