Skip to content

Commit

Permalink
Fix apt subcommand option completions
Browse files Browse the repository at this point in the history
  • Loading branch information
radek-sprta authored and Kurtis Rader committed Aug 23, 2017
1 parent 240bb25 commit 27d7fea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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).
Expand Down
24 changes: 20 additions & 4 deletions share/completions/apt.fish
Expand Up @@ -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
Expand All @@ -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'
Expand Down

0 comments on commit 27d7fea

Please sign in to comment.