Fix apt subcommand option completions

This commit is contained in:
Radek SPRTA 2017-08-21 22:30:10 +02:00 committed by Kurtis Rader
parent 240bb25dbe
commit 27d7feaf95
2 changed files with 21 additions and 4 deletions

View file

@ -28,6 +28,7 @@
- `read` failures due to too much data should define the var (#4180). - `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). - 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). - 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: - Added completions for:
- `as` (#4130). - `as` (#4130).
- `jest` (#4142). - `jest` (#4142).

View file

@ -19,10 +19,26 @@ function __fish_apt_use_package --description 'Test if apt command should have p
end end
function __fish_apt_subcommand 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 complete -f -c apt -n '__fish_apt_no_subcommand' -a $subcommand $argv
end 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' complete -c apt -n '__fish_apt_use_package' -a '(__fish_print_packages)' --description 'Package'
# Support flags # Support flags
@ -36,9 +52,9 @@ complete -f -c apt -s t --description 'Target release'
# List # List
__fish_apt_subcommand list --description 'List packages' __fish_apt_subcommand list --description 'List packages'
__fish_apt_subcommand list -l installed --description 'Installed packages' __fish_apt_option list -l installed --description 'Installed packages'
__fish_apt_subcommand list -l upgradable --description 'Upgradable packages' __fish_apt_option 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 all-versions --description 'Show all versions of any package'
# Search # Search
__fish_apt_subcommand search -r --description 'Search for packages' __fish_apt_subcommand search -r --description 'Search for packages'