forked from danielfoehrKn/kubeswitch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_switch.bash
87 lines (76 loc) · 1.36 KB
/
_switch.bash
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
_kube_contexts()
{
local curr_arg;
curr_arg=${COMP_WORDS[COMP_CWORD]}
# if not the first argument, and the previous one is not a flag (so it is a command)
if [ "$COMP_CWORD" -gt 1 ]; then
case ${COMP_WORDS[COMP_CWORD - 1]} in
alias*)
arguments="ls
rm
--state-directory
--config-path
--kubeconfig-name
--kubeconfig-path
--store
--vault-api-address
--help"
;;
clean*)
arguments=""
;;
hooks*)
arguments="ls
--config-path
--hook-name
--run-immediately
--state-directory
--help"
;;
list-contexts*)
arguments="--config-path
--kubeconfig-name
--kubeconfig-path
--state-directory
--store
--vault-api-address
--help"
;;
*)
arguments=""
;;
esac
if [[ $arguments != "" ]]; then
COMPREPLY=( $(compgen -W "$arguments") );
return
fi
fi
if [[ $curr_arg != --* ]]; then
contexts=$(switch list-contexts)
fi
COMPREPLY=( $(compgen -W "history
help
clean
hooks
alias
list-contexts
--kubeconfig-path
--store
--kubeconfig-name
--show-preview
--vault-api-address
--executable-path
--state-directory
--config-path
--help
-c
--current
-d
-u
--unset
-
-v
version
$contexts " -- $curr_arg ) );
}
complete -F _kube_contexts switch