From f4acb49ea148cdd899f7f29f1591c7bc853c2135 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 03:03:18 +0200 Subject: Adding upstream version 1:2.12.0. Signed-off-by: Daniel Baumann --- completions/apt-cache | 98 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 70 insertions(+), 28 deletions(-) (limited to 'completions/apt-cache') 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 -- cgit v1.2.3