Fix apt subcommand option completions

(cherry picked from commit 27d7feaf95)
This commit is contained in:
Radek SPRTA 2017-08-21 22:30:10 +02:00 committed by Kurtis Rader
parent ba53242b26
commit 04bd4c4b4e
2 changed files with 21 additions and 4 deletions

View File

@ -53,6 +53,7 @@ This section is for changes merged to the `major` branch that are not also merge
- `read` failures due to too much data should define the var (#4180).
- multiple `read` commands in non-interactive scripts were broken in fish 2.6.0 (#4206).
- Fix regression involving universal variables with side-effects at startup such as `set -U fish_escape_delay_ms 10` (#4196).
- Option completion for `apt list` now works properly (#4350).
- Added completions for:
- `as` (#4130).
- `jest` (#4142).

View File

@ -19,10 +19,26 @@ function __fish_apt_use_package --description 'Test if apt command should have p
end
function __fish_apt_subcommand
set subcommand $argv[1]; set -e argv[1]
set subcommand $argv[1]
set -e argv[1]
complete -f -c apt -n '__fish_apt_no_subcommand' -a $subcommand $argv
end
function __fish_apt_using_subcommand --description 'Test if given subcommand is used'
for i in (commandline -opc)
if contains -- $i $argv
return 0
end
end
return 1
end
function __fish_apt_option
set subcommand $argv[1]
set -e argv[1]
complete -f -c apt -n "__fish_apt_using_subcommand $subcommand" $argv
end
complete -c apt -n '__fish_apt_use_package' -a '(__fish_print_packages)' --description 'Package'
# Support flags
@ -36,9 +52,9 @@ complete -f -c apt -s t --description 'Target release'
# List
__fish_apt_subcommand list --description 'List packages'
__fish_apt_subcommand list -l installed --description 'Installed packages'
__fish_apt_subcommand list -l upgradable --description 'Upgradable packages'
__fish_apt_subcommand list -l all-versions --description 'Show all versions of any package'
__fish_apt_option list -l installed --description 'Installed packages'
__fish_apt_option list -l upgradable --description 'Upgradable packages'
__fish_apt_option list -l all-versions --description 'Show all versions of any package'
# Search
__fish_apt_subcommand search -r --description 'Search for packages'