mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
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
This commit is contained in:
parent
126c8c14b8
commit
37f4cbe3d7
@ -18,21 +18,17 @@ function __fish_apm_needs_command
|
|||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns exit code of 0 if a command (argv[1]) appears once, exclusions can
|
# Returns exit code of 0 if any command (argv[1..-1]) appears once, ignores flags.
|
||||||
# can be provided (argv[2..-1]) that are ignored, e.g. `get` and `set`
|
|
||||||
function __fish_apm_using_command
|
function __fish_apm_using_command
|
||||||
set command $argv[1]
|
set commands $argv
|
||||||
if test (count $argv) -gt 1
|
|
||||||
set exclusions $argv[2..-1]
|
|
||||||
end
|
|
||||||
set cmd (commandline -opc)
|
set cmd (commandline -opc)
|
||||||
if test (count $cmd) -gt 1
|
if test (count $cmd) -gt 1
|
||||||
set -l command_seen_once 1
|
set -l command_seen_once 1
|
||||||
for c in $cmd[2..-1]
|
for c in $cmd[2..-1]
|
||||||
switch $c
|
switch $c
|
||||||
case '--color' '--no-color' $exclusions
|
case '-*'
|
||||||
continue
|
continue
|
||||||
case $argv
|
case $commands
|
||||||
# If the command is seen more than once then return 1
|
# If the command is seen more than once then return 1
|
||||||
if test $command_seen_once -eq 1
|
if test $command_seen_once -eq 1
|
||||||
set command_seen_once 0
|
set command_seen_once 0
|
||||||
@ -40,7 +36,11 @@ function __fish_apm_using_command
|
|||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
case '*'
|
case '*'
|
||||||
return 1
|
if test $command_seen_once -eq 0
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return $command_seen_once
|
return $command_seen_once
|
||||||
|
Loading…
x
Reference in New Issue
Block a user