diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:18 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:18 +0000 |
commit | f4acb49ea148cdd899f7f29f1591c7bc853c2135 (patch) | |
tree | b62d60873864065d6428a84a119dd8a3c90f1397 /completions/apt-cache | |
parent | Adding upstream version 1:2.11. (diff) | |
download | bash-completion-f4acb49ea148cdd899f7f29f1591c7bc853c2135.tar.xz bash-completion-f4acb49ea148cdd899f7f29f1591c7bc853c2135.zip |
Adding upstream version 1:2.12.0.upstream/1%2.12.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'completions/apt-cache')
-rw-r--r-- | completions/apt-cache | 98 |
1 files changed, 70 insertions, 28 deletions
diff --git a/completions/apt-cache b/completions/apt-cache index 61aa07b..1f47d7d 100644 --- a/completions/apt-cache +++ b/completions/apt-cache @@ -1,32 +1,69 @@ # Debian apt-cache(8) completion -*- shell-script -*- # List APT binary packages +# @since 2.12 +_comp_xfunc_apt_cache_compgen_packages() +{ + _comp_cmd_apt_cache__compgen_packages apt-cache +} + +# List APT binary packages +# @param $1 Name of executable +_comp_cmd_apt_cache__compgen_packages() +{ + _comp_compgen_split -- "$("$1" --no-generate pkgnames "$cur" 2>/dev/null)" +} + +# List APT source packages +# @since 2.12 +_comp_xfunc_apt_cache_compgen_sources() +{ + _comp_cmd_apt_cache__compgen_sources apt-cache +} + +# List APT source packages +# @param $1 Name of executable +_comp_cmd_apt_cache__compgen_sources() +{ + _comp_compgen_split -- "$("$1" dumpavail | + _comp_awk '$1 == "Source:" { print $2 }' | sort -u)" +} + +# List APT binary packages +# @deprecated 2.12 _apt_cache_packages() { - apt-cache --no-generate pkgnames "$cur" 2>/dev/null || : + local packages + _comp_compgen -v packages -i apt-cache packages apt-cache && + printf '%s\n' "${packages[@]}" } # List APT source packages +# @deprecated 2.12 _apt_cache_sources() { - compgen -W "$(apt-cache dumpavail | - awk '$1 == "Source:" { print $2 }' | sort -u)" -- "$1" + local sources + _comp_compgen -v sources -c "$1" -i apt-cache sources apt-cache && + printf '%s\n' "${sources[@]}" } # List APT source packages +# @deprecated 2.12 _apt_cache_src_packages() { - compgen -W '$(_apt_cache_sources "$cur")' -- "$cur" + local sources + _comp_compgen -v sources -i apt-cache sources apt-cache && + printf '%s\n' "${sources[@]}" } -_apt_cache() +_comp_cmd_apt_cache() { - local cur prev words cword - _init_completion || return + local cur prev words cword comp_args + _comp_initialize -- "$@" || return - local special ispecial + local special="" ispecial if [[ $cur != show ]]; then - for ((ispecial = 1; ispecial < ${#words[@]} - 1; ispecial++)); do + for ((ispecial = 1; ispecial < ${#words[@]}; ispecial++)); do if [[ ${words[ispecial]} == @(add|depends|dotty|madison|policy|rdepends|show?(pkg|src|)) ]]; then special=${words[ispecial]} break @@ -34,27 +71,34 @@ _apt_cache() done fi - if [[ -v special && $ispecial -lt $cword ]]; then + if [[ $special && $ispecial -lt $cword ]]; then case $special in add) - _filedir + _comp_compgen_filedir ;; showsrc) - COMPREPLY=($(_apt_cache_sources "$cur")) + _comp_cmd_apt_cache__compgen_sources "$1" ;; *) - COMPREPLY=($(_apt_cache_packages)) + _comp_cmd_apt_cache__compgen_packages "$1" ;; esac return fi + local noargopts='!(-*|*[cps]*)' + # shellcheck disable=SC2254 case $prev in - --config-file | --pkg-cache | --src-cache | -!(-*)[cps]) - _filedir + --config-file | --pkg-cache | --src-cache | -${noargopts}[cps]) + _comp_compgen_filedir + return + ;; + --with-source) + _comp_compgen_filedir '@(deb|dsc|changes)' + _comp_compgen -a -- -f -o plusdirs -X '!?(*/)@(Sources|Packages)' return ;; search) @@ -65,21 +109,19 @@ _apt_cache() esac if [[ $cur == -* ]]; then - - COMPREPLY=($(compgen -W '-h -v -p -s -q -i -f -a -g -c -o --help - --version --pkg-cache --src-cache --quiet --important --full - --all-versions --no-all-versions --generate --no-generate - --names-only --all-names --recurse --config-file --option - --installed' -- "$cur")) - elif [[ ! -v special ]]; then - - COMPREPLY=($(compgen -W 'add gencaches show showpkg showsrc stats - dump dumpavail unmet search search depends rdepends pkgnames - dotty xvcg policy madison' -- "$cur")) - + _comp_compgen -- -W '--pkg-cache --src-cache --quiet --important + --no-pre-depends --no-depends --no-recommends --no-suggests + --no-conflicts --no-breaks --no-replaces --no-enhances --implicit + --full --all-versions --no-all-versions --generate --no-generate + --names-only --all-names --recurse --installed --with-source + --help --version --config-file --option' + elif [[ ! $special ]]; then + _comp_compgen -- -W 'gencaches showpkg stats showsrc dump dumpavail + unmet show search depends rdepends pkgnames dotty xvcg policy + madison' fi } && - complete -F _apt_cache apt-cache + complete -F _comp_cmd_apt_cache apt-cache # ex: filetype=sh |