diff --git a/CHANGELOG.md b/CHANGELOG.md index f1370c9859d4..f7ad1a0d1b38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ - `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). diff --git a/share/completions/apt.fish b/share/completions/apt.fish index 6139fe43d41e..6448694aa4dd 100644 --- a/share/completions/apt.fish +++ b/share/completions/apt.fish @@ -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'