Skip to content

Commit b2ab72f

Browse files
authored
Merge pull request #988 from scop/refactor/util-func-cmds-2
refactor: more util/xfunc primary command convention adjustments
2 parents 9b443a9 + b85263a commit b2ab72f

20 files changed

+74
-8
lines changed

completions/add_members

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ _comp_cmd_add_members()
2222
_comp_compgen -- -W '--regular-members-file --digest-members-file
2323
--welcome-msg --admin-notify --help'
2424
else
25+
# Prefer `list_lists` in the same dir as command
26+
local pathcmd
27+
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
2528
_comp_xfunc list_lists mailman_lists
2629
fi
2730

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

completions/apt-get

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ _comp_cmd_apt_get()
3434
_comp_xfunc_apt_get_installed_packages
3535
;;
3636
source)
37+
# Prefer `apt-cache` in the same dir as command
38+
local pathcmd
39+
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
3740
COMPREPLY=($(_comp_xfunc apt-cache packages)
3841
$(compgen -W "$(apt-cache dumpavail |
3942
awk '$1 == "Source:" { print $2 }' | sort -u)" -- "$cur"))
@@ -78,6 +81,9 @@ _comp_cmd_apt_get()
7881
return
7982
;;
8083
--target-release | --default-release | -${noargopts}t)
84+
# Prefer `apt-cache` in the same dir as command
85+
local pathcmd
86+
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
8187
COMPREPLY=($(compgen -W "$(apt-cache policy | command sed -ne \
8288
's/^ *release.*[ ,]o=\(Debian\|Ubuntu\),a=\(\w*\).*/\2/p')" \
8389
-- "$cur"))

completions/arch

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ _comp_have_command mailmanctl &&
3232
done
3333
case $args in
3434
1)
35+
# Prefer `list_lists` in the same dir as command
36+
local pathcmd
37+
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
3538
_comp_xfunc list_lists mailman_lists
3639
;;
3740
2)

completions/change_pw

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ _comp_cmd_change_pw()
77

88
case $prev in
99
-l | --listname)
10+
# Prefer `list_lists` in the same dir as command
11+
local pathcmd
12+
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
1013
_comp_xfunc list_lists mailman_lists
1114
return
1215
;;

completions/check_db

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ _comp_cmd_check_db()
88
if [[ $cur == -* ]]; then
99
_comp_compgen -- -W '--all --verbose --help'
1010
else
11+
# Prefer `list_lists` in the same dir as command
12+
local pathcmd
13+
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
1114
_comp_xfunc list_lists mailman_lists
1215
fi
1316

completions/clone_member

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ _comp_cmd_clone_member()
77

88
case $prev in
99
-l | --listname)
10+
# Prefer `list_lists` in the same dir as command
11+
local pathcmd
12+
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
1013
_comp_xfunc list_lists mailman_lists
1114
return
1215
;;

completions/config_list

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ _comp_cmd_config_list()
1818
COMPREPLY=($(compgen -W '--inputfile --outputfile --checkonly
1919
--verbose --help' -- "$cur"))
2020
else
21+
# Prefer `list_lists` in the same dir as command
22+
local pathcmd
23+
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
2124
_comp_xfunc list_lists mailman_lists
2225
fi
2326

completions/find_member

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ _comp_cmd_find_member()
77

88
case $prev in
99
-l | -x | --listname | --exclude)
10+
# Prefer `list_lists` in the same dir as command
11+
local pathcmd
12+
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
1013
_comp_xfunc list_lists mailman_lists
1114
return
1215
;;

completions/inject

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ _comp_cmd_inject()
77

88
case $prev in
99
-l | --listname)
10+
# Prefer `list_lists` in the same dir as command
11+
local pathcmd
12+
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
1013
_comp_xfunc list_lists mailman_lists
1114
return
1215
;;

0 commit comments

Comments
 (0)