Skip to content

Commit 97753b7

Browse files
committed
refactor(apt-cache): _comp_xfunc_* main cmd convention
1 parent a731bfd commit 97753b7

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

completions/apt-cache

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,36 @@
55
# @since 2.12
66
_comp_xfunc_apt_cache_packages()
77
{
8-
apt-cache --no-generate pkgnames "$cur" 2>/dev/null || :
8+
_comp_cmd_apt_cache__packages apt-cache
9+
}
10+
11+
# TODO:API: rework to use vars rather than outputting
12+
_comp_cmd_apt_cache__packages()
13+
{
14+
"$1" --no-generate pkgnames "$cur" 2>/dev/null || :
915
}
1016

1117
# List APT source packages
1218
# TODO:API: rework to use vars rather than outputting
1319
# @since 2.12
1420
_comp_xfunc_apt_cache_sources()
1521
{
16-
compgen -W "$(apt-cache dumpavail |
17-
awk '$1 == "Source:" { print $2 }' | sort -u)" -- "$1"
22+
_comp_cmd_apt_cache__sources apt-cache "$1"
23+
}
24+
25+
# TODO:API: rework to use vars rather than outputting
26+
_comp_cmd_apt_cache__sources()
27+
{
28+
compgen -W "$("$1" dumpavail |
29+
awk '$1 == "Source:" { print $2 }' | sort -u)" -- "$2"
1830
}
1931

2032
# List APT source packages
2133
# TODO:API: rework to use vars rather than outputting
2234
# @since 2.12
2335
_comp_xfunc_apt_cache_src_packages()
2436
{
25-
compgen -W '$(_comp_xfunc_apt_cache_sources "$cur")' -- "$cur"
37+
compgen -W '$(_comp_cmd_apt_cache__sources apt-cache "$cur")' -- "$cur"
2638
}
2739

2840
_comp_deprecate_func 2.12 _apt_cache_packages _comp_xfunc_apt_cache_packages
@@ -52,11 +64,11 @@ _comp_cmd_apt_cache()
5264
;;
5365

5466
showsrc)
55-
COMPREPLY=($(_comp_xfunc_apt_cache_sources "$cur"))
67+
COMPREPLY=($(_comp_cmd_apt_cache__sources "$1" "$cur"))
5668
;;
5769

5870
*)
59-
COMPREPLY=($(_comp_xfunc_apt_cache_packages))
71+
COMPREPLY=($(_comp_cmd_apt_cache__packages "$1"))
6072
;;
6173

6274
esac

0 commit comments

Comments
 (0)