-
Notifications
You must be signed in to change notification settings - Fork 33
/
init_obdiag_cmd.sh
66 lines (64 loc) · 2.75 KB
/
init_obdiag_cmd.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
57
58
59
60
61
62
63
64
65
66
_obdiag_completion() {
local cur_word args type_list
cur_word="${COMP_WORDS[COMP_CWORD]}"
args="${COMP_WORDS[@]:1}"
case "${COMP_CWORD}" in
1)
type_list="--version display-trace config gather display analyze check rca update"
COMPREPLY=($(compgen -W "${type_list}" -- "${cur_word}"))
;;
2)
case "${COMP_WORDS[1]}" in
gather)
if [ "$COMP_CWORD" -eq 2 ]; then
type_list="log clog slog plan_monitor stack perf sysstat obproxy_log all scene ash tabledump parameter variable"
elif [ "${COMP_WORDS[2]}" = "scene" ] && [ "$COMP_CWORD" -eq 3 ]; then
type_list="list run"
fi
;;
display)
if [ "$COMP_CWORD" -eq 2 ]; then
type_list="scene"
elif [ "${COMP_WORDS[2]}" = "scene" ] && [ "$COMP_CWORD" -eq 3 ]; then
type_list="list run"
fi
;;
analyze)
if [ "$COMP_CWORD" -eq 2 ]; then
type_list="log flt_trace parameter variable index_space queue memory"
elif [ "${COMP_WORDS[2]}" = "parameter" ] && [ "$COMP_CWORD" -eq 3 ]; then
type_list="diff default"
elif [ "${COMP_WORDS[2]}" = "variable" ] && [ "$COMP_CWORD" -eq 3 ]; then
type_list="diff"
fi
;;
rca)
type_list="list run"
;;
*)
type_list=""
;;
esac
COMPREPLY=($(compgen -W "${type_list}" -- "${cur_word}"))
;;
3)
if [ "${COMP_WORDS[1]}" = "gather" ] && [ "${COMP_WORDS[2]}" = "scene" ]; then
type_list="list run"
COMPREPLY=($(compgen -W "${type_list}" -- "${cur_word}"))
elif [ "${COMP_WORDS[1]}" = "display" ] && [ "${COMP_WORDS[2]}" = "scene" ]; then
type_list="list run"
COMPREPLY=($(compgen -W "${type_list}" -- "${cur_word}"))
elif [ "${COMP_WORDS[1]}" = "analyze" ] && [ "${COMP_WORDS[2]}" = "parameter" ]; then
type_list="diff default"
COMPREPLY=($(compgen -W "${type_list}" -- "${cur_word}"))
elif [ "${COMP_WORDS[1]}" = "analyze" ] && [ "${COMP_WORDS[2]}" = "variable" ]; then
type_list="diff"
COMPREPLY=($(compgen -W "${type_list}" -- "${cur_word}"))
fi
;;
*)
COMPREPLY=()
;;
esac
}
complete -F _obdiag_completion obdiag