-
Notifications
You must be signed in to change notification settings - Fork 3
/
_wenv
79 lines (72 loc) · 2.35 KB
/
_wenv
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
#compdef wenv
local state
integer ret=1
list_wenvs() {
find "$WENV_CFG/wenvs" ! -name ".gitignore" ! -path '*/\.git/*' ! -type d | perl -pe "s|$WENV_CFG/wenvs/||"
}
list_extensions() {
find "$WENV_CFG/extensions/" ! -type d | perl -pe "s|$WENV_CFG/extensions/||"
}
_arguments -C \
':command:(start stop cd new edit rm mv source extension bootstrap exec)' \
'*::arg:->args' && ret=0
case "$line[1]" in
start)
_arguments "-i[Do not run wenv's startup function]" "-d[Do not attach to wenv's tmux session]" "-h[Show help message]" "*:wenvs:($(list_wenvs))" && ret=0
;;
stop)
_arguments "-f[Force shutdown even if shutdown_wenv fails]" "-s[Do not run shutdown function]" "-h[Show help message]" && ret=0
;;
cd)
_arguments "-h[Show help message]" "*:wenvs:($(list_wenvs))" && ret=0
;;
new)
_arguments "-d[Wenv's base directory]:directory" "-i[Initial wenv to copy]:initial_wenv:->wenv" "-h[Show help message]" "1: :->wenv" && ret=0
case $state in
wenv) _describe 'command' "($(list_wenvs))" ;;
esac
;;
edit)
_arguments "-h[Show help message]" "1: :->wenv" && ret=0
case $state in
wenv) _describe 'command' "($(list_wenvs))" ;;
esac
;;
ls|list)
_arguments "-h[Show help message]" "1: :->wenv" && ret=0
case $state in
wenv) _describe 'command' "($(list_wenvs))" ;;
esac
;;
rm)
_arguments "-h[Show help message]" "1: :->wenv" && ret=0
case $state in
wenv) _describe 'command' "($(list_wenvs))" ;;
esac
;;
mv)
_arguments "-h[Show help message]" "1:src:->wenv" "2:dst:->wenv" && ret=0
case $state in
wenv) _describe 'command' "($(list_wenvs))" ;;
esac
;;
source)
_arguments "-h[Show help message]" && ret=0
;;
extension)
_arguments -C \
"-h[Show help message]" \
':command:(edit load rm)' \
'*::arg:->args' && ret=0
(($#line == 2)) && case "$line[1]" in
edit|load|rm) _describe 'command' "($(list_extensions))" ;;
esac
;;
bootstrap)
_arguments "-h[Show help message]" && ret=0
;;
exec)
_arguments "-h[Show help message]" && ret=0
;;
esac
return $ret