-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathzabbix_proxy-completion
60 lines (54 loc) · 1.61 KB
/
zabbix_proxy-completion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#
# Bash completion for zabbix_proxy
#
shopt -s extglob
_zabbix_proxy()
{
local cur prev opts unique_opts nonunique_opts unique_opts_space nonunique_opts_space opt option
local runtime_simple_options="config_cache_reload housekeeper_execute snmp_cache_reload diaginfo"
local diaginfo_params="historycache locks preprocessing"
COMPREPLY=()
_get_comp_words_by_ref -n = cur prev
unique_opts="-h|--help|-V|--version"
nonunique_opts="-c|-R|-f|--config|--runtime-control|--foreground"
unique_opts_space=${unique_opts//|/ }
nonunique_opts_space=${nonunique_opts//|/ }
opts=" $unique_opts_space $nonunique_opts_space "
for (( i=1; i<=$[${#COMP_WORDS[@]}-1]; ++i )) ; do
opt=${COMP_WORDS[$i]}
[[ $opt =~ --*[hvVcRrf].* ]] && {
option=$opt
} || {
continue
}
# if a unique option has been supplied, do not offer any other options
[[ $option == @($unique_opts) ]] && {
return 1
}
# if a non-unique option has been supplied, remove all unique options and already used options
[[ $option == @($nonunique_opts) ]] && opts="${opts/$unique_opts_space/}"
opts=${opts/ $option / }
# remove alternatives
case $option in
-R) opts="${opts/ --runtime-control/}" ;;
--runtime-control) opts="${opts/ -R/}" ;;
-c) opts="${opts/ --config/}" ;;
--config) opts="${opts/ -c/}" ;;
esac
done
case "${prev}" in
-@(c|-config))
compopt -o default
COMPREPLY=()
return 0
;;
-@(R|-runtime-control))
_zabbix-daemons-runtime "$cur" proxy $1
return 0
;;
*)
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
}
complete -F _zabbix_proxy zabbix_proxy