-
Notifications
You must be signed in to change notification settings - Fork 0
/
cruise-completion
105 lines (84 loc) · 2.66 KB
/
cruise-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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env bash
_cruise_autocomplete() {
local cursor prev_word commands options
COMPREPLY=()
cursor="${COMP_WORDS[COMP_CWORD]}"
prev_word="${COMP_WORDS[COMP_CWORD-1]}"
commands="environments build start stop restart shell root-shell export import remove create traefik code install uninstall"
case "${prev_word}" in
build | stop)
COMPREPLY=( -v -f )
return 0
;;
start)
COMPREPLY=( -v -n -p -e -s -c -l -b )
return 0
;;
traefik)
COMPREPLY=( -v -n -s -c -l -b )
return 0
;;
import)
COMPREPLY=( $(compgen -f "${cursor}") )
return 0
;;
create | export | restart | code)
COMPREPLY=( -v )
return 0
;;
remove)
COMPREPLY=( $(docker ps -a --format '{{.Names}}' | grep 'cruise') )
return 0
;;
shell)
COMPREPLY=( -v -n -e -u -b )
return 0
;;
root-shell)
COMPREPLY=( -v -n -e -b )
return 0
;;
environments | install | uninstall)
COMPREPLY=()
return 0
;;
-v)
if [[ "${COMP_WORDS[@]}" = *build* ]]; then
COMPREPLY=( $(ls "$HOME/.cruise/environments") )
fi
if [[ "${COMP_WORDS[@]}" = *create* ]]; then
COMPREPLY=( $(ls "$HOME/.cruise/environments") )
fi
if [[ "${COMP_WORDS[@]}" = *export* ]]; then
COMPREPLY=( $(ls "$HOME/.cruise/environments") )
fi
if [[ "${COMP_WORDS[@]}" = *restart* ]]; then
COMPREPLY=( $(ls "$HOME/.cruise/environments") )
fi
if [[ "${COMP_WORDS[@]}" = *code* ]]; then
COMPREPLY=( $(ls "$HOME/.cruise/environments") )
fi
return 0
;;
-f)
if [[ "${COMP_WORDS[@]}" = *build* ]]; then
COMPREPLY=( -v )
fi
return 0
;;
-s)
if [[ "${COMP_WORDS[@]}" = *start* ]]; then
COMPREPLY=( nginx octane )
fi
if [[ "${COMP_WORDS[@]}" = *traefik* ]]; then
COMPREPLY=( nginx octane )
fi
return 0
;;
*)
COMPREPLY=( $(compgen -W "${commands}" -- ${cursor}) )
return 0
;;
esac
}
complete -F _cruise_autocomplete cruise