-
Notifications
You must be signed in to change notification settings - Fork 44
/
datakit-completer.sh
56 lines (43 loc) · 1.65 KB
/
datakit-completer.sh
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
# DataKit completion -*- shell-script -*-
# We should copy this script to /etc/bash_completion.d/datakit for unbuntu
# For Centos relalted Linux, we need more test.
_datakit()
{
local cur_word prev_word
cur_word="${COMP_WORDS[COMP_CWORD]}"
prev_word="${COMP_WORDS[COMP_CWORD-1]}"
cmd=${COMP_WORDS[1]}
if [[ -n $cmd ]]; then # we have select specified command
case "${cmd}" in
dql)
COMPREPLY=( $(compgen -W '--auto-json --csv -F,--force --host -J,--json --log -R,--run -T,--token -V,--verbose' -- "${cur_word}") )
;;
pipeline)
COMPREPLY=( $(compgen -W '--date -F,--file --log --tab -T,--txt' -- "${cur_word}") )
;;
monitor)
COMPREPLY=( $(compgen -W '-I,--input --log -W,--max-table-width -R,--refresh --to -V,--verbose' -- "${cur_word}") )
;;
service)
COMPREPLY=( $(compgen -W '--log -I,--reinstall -R,--restart -S,--start -T,--stop -U,--uninstall' -- "${cur_word}") )
;;
install)
COMPREPLY=( $(compgen -W '--log --ipdb --log --scheck --telegraf' -- "${cur_word}") )
;;
tool)
COMPREPLY=( $(compgen -W '--default-main-conf --dump-samples --ipinfo --log
--show-cloud-info --upload-log --workspace-info --setup-completer-script' -- "${cur_word}") )
;;
help)
COMPREPLY=( $(compgen -W 'dql run pipeline service monitor install tool' -- "${cur_word}") )
;;
*)
COMPREPLY=( $(compgen -W 'dql run pipeline service monitor install tool help' -- "${cur_word}") )
;;
esac
else # command not selected
COMPREPLY=( $(compgen -W 'dql run pipeline service monitor install tool help' -- "${cur_word}") )
fi
} &&
complete -F _datakit datakit ddk
# ex: filetype=sh