3
3
# TODO:API: rename per conventions, rework to use vars rather than outputting
4
4
_dictdata ()
5
5
{
6
- # shellcheck disable=SC2086
7
- dict $host $port $1 2> /dev/null | command sed -ne \
6
+ dict " $@ " 2> /dev/null | command sed -ne \
8
7
' s/^[[:blank:]]\{1,\}\([^[:blank:]]*\).*$/\1/p'
9
8
}
10
9
@@ -13,6 +12,7 @@ _comp_cmd_dict()
13
12
local cur prev words cword comp_args
14
13
_comp_initialize -- " $@ " || return
15
14
15
+ local -a dict_options=()
16
16
local host=" " port=" " db i
17
17
18
18
local noargopts=' !(-*|*[hpdis]*)'
@@ -21,15 +21,15 @@ _comp_cmd_dict()
21
21
case ${words[i]} in
22
22
--host | -${noargopts} h)
23
23
host=${words[++i]}
24
- [[ $host ]] && host= " -h $host "
24
+ [[ $host ]] && dict_options+=( -h " $host " )
25
25
;;
26
26
--port | -${noargopts} p)
27
27
port=${words[++i]}
28
- [[ $port ]] && port= " -p $port "
28
+ [[ $port ]] && dict_options+=( -p " $port " )
29
29
;;
30
30
--database | -${noargopts} d)
31
31
db=${words[++i]}
32
- [[ $db ]] && host= " -d $db "
32
+ [[ $db ]] && dict_options+=( -d " $db " )
33
33
;;
34
34
esac
35
35
done
@@ -42,11 +42,11 @@ _comp_cmd_dict()
42
42
# shellcheck disable=SC2254
43
43
case $prev in
44
44
--database | -info | -${noargopts} [di])
45
- _comp_compgen_split -- " $( _dictdata -D) "
45
+ _comp_compgen_split -- " $( _dictdata " ${dict_options[@]} " -D) "
46
46
return
47
47
;;
48
48
--strategy | -${noargopts} s)
49
- _comp_compgen_split -- " $( _dictdata -S) "
49
+ _comp_compgen_split -- " $( _dictdata " ${dict_options[@]} " -S) "
50
50
return
51
51
;;
52
52
esac
0 commit comments