This repository has been archived by the owner on Dec 20, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
avoscloud_completion.sh
88 lines (86 loc) · 2.48 KB
/
avoscloud_completion.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# bash completion support for avoscloud
# Copyright (C) 2014, AVOS Cloud <support@avoscloud.com>
# Distributed under the GNU General Public License, version 2.0.
# Usage:
#
# 1) Copy this file to somewhere (e.g. ~/.avoscloud_completion.sh).
# 2) Add the following line to your .bashrc/.bash_profile
# source ~/.avoscloud_completion.sh
_apps()
{
if [[ -a ".avoscloud/apps.json" ]]; then
local words
words=$(node -e "var obj=require('./.avoscloud/apps.json');for(var k in obj) console.log(k)")
COMPREPLY=( $( compgen -W '$words' -- ${cur}))
fi
}
_avoscloud()
{
local cur prev
_get_comp_words_by_ref cur prev
COMPREPLY=()
case $prev in
-h|-V)
return 0
;;
up)
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-d --debug -P --port' -- "$cur" ) )
return 0
fi
;;
deploy)
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-o --log -g --git -r --revision --app --noCache' -- "$cur" ) )
return 0
fi
;;
publish|status|undeploy|cql|upload|clear)
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--app' -- "$cur" ) )
return 0
fi
;;
group)
COMPREPLY=( $( compgen -W 'list deploy undeploy' -- "$cur" ) )
return 0
;;
instance)
COMPREPLY=( $( compgen -W 'list new rm' -- "$cur" ) )
return 0
;;
logs)
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-n --lines -t --tailf -e --env --app' -- "$cur" ) )
return 0
fi
;;
app)
COMPREPLY=( $( compgen -W 'list add checkout rm' -- "$cur" ) )
return 0
;;
checkout|rm)
_apps
return 0
;;
redis)
COMPREPLY=( $( compgen -W 'list conn' -- "$cur" ) )
return 0
;;
--app)
_apps
return 0
;;
-e)
COMPREPLY=( $( compgen -W 'stg prod' -- "$cur" ) )
return 0
;;
esac
COMPREPLY=( $( compgen -W 'search new up deploy publish status undeploy
image instance
logs app cql redis upload clear
' -- "$cur" ) )
return 0
} &&
complete -F _avoscloud avoscloud
complete -F _avoscloud lean