-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathabb.bash_completion
205 lines (183 loc) · 5.25 KB
/
abb.bash_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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# bash completion for abb
_have abb && {
_abb() {
local commands cur prev words cword specs IFS sifs=$IFS
local rpmbuildopts ncur varvalue varvalue1 branch updatetypes
local opts opts_view opts_status opts_restore opts_build
local opts_publish opts_store opts_clone opts_new
COMPREPLY=()
_get_comp_words_by_ref -n '=' cur prev words cword
#echo "cword=$cword cur='$cur' '${words[@]}'" >> /tmp/log
specs=$(basename -s .spec $(ls *.spec 2>/dev/null) 2>/dev/null)
commands="build
clone
new
publish
restore
send
status
store
vars
view"
rpmbuildopts="-ba
-bb
-bc
-bi
-bl
-bp
-bs
--short-circuit"
opts="proto= server= owner= branch= remote= auth= abfyml= buildlog= \
restore= project= rows= refresh= defaultspec= \
arch= platform= updatetype= commit= publish= repos= reposave= withrequired="
opts_send="proto= server= owner= branch= auth= project= arch= platform= \
updatetype= commit= publish= repos= reposave= withrequired="
opts_view="proto= server= owner= auth= project="
opts_status="proto= server= owner= auth= project= rows= refresh="
opts_restore="abfyml= project="
opts_build="proto= server= owner= branch= remote= auth= abfyml= buildlog= \
restore= project="
opts_publish="proto= server= auth="
opts_store="auth= abfyml="
opts_clone="proto= server= owner= branch= remote= auth= abfyml= \
restore= project="
opts_new="proto= server= owner= remote= auth= \
project= defaultspec="
updatetypes="security bugfix enhancement recommended newpackage"
if [ $cword -eq 1 ]; then
IFS=$'\t'$'\n'
COMPREPLY=( $( compgen -W "$commands" -S ' ' -- "$cur" ) )
IFS=$sifs
return 0
fi
if [[ "$cur" == -* ]]; then
IFS=$'\t'$'\n'
COMPREPLY=( $( compgen -W "$rpmbuildopts" -S ' ' -- "$cur" ) )
IFS=$sifs
return 0
fi
if [[ "$cur" == *=* ]]; then
ncur=${cur#*=}
varvalue="$(abb vars ${cur%=*})"
varvalue="${varvalue[@]##*=}"
case "$cur" in
proto=*)
COMPREPLY=( $( compgen -W "http https $varvalue" -- "$ncur" ) )
;;
server=*)
COMPREPLY=( $( compgen -W "abf.rosalinux.ru $varvalue" -- "$ncur" ) )
;;
owner=*)
COMPREPLY=( $( compgen -W "import npp_team tigro $varvalue" -- "$ncur" ) )
;;
branch=*)
COMPREPLY=( $( compgen -W "master rosa2012lts rosa2012.1 import_cooker import_mandriva2011 $varvalue" -- "$ncur" ) )
;;
remote=*)
COMPREPLY=( $( compgen -W "origin $varvalue" -- "$ncur" ) )
;;
auth=*)
COMPREPLY=( $( compgen -W "$varvalue" -- "$ncur" ) )
;;
abfyml=*)
COMPREPLY=( $( compgen -W ".abf.yml $varvalue" -- "$ncur" ) )
;;
buildlog=*)
COMPREPLY=( $( compgen -W "yes no $varvalue" -- "$ncur" ) )
;;
restore=*)
COMPREPLY=( $( compgen -W "always ask none $varvalue" -- "$ncur" ) )
;;
project=*)
COMPREPLY=( $( compgen -d -W "$specs $varvalue" -- "$cur" ) )
;;
rows=*)
COMPREPLY=( $( compgen -W "4 $varvalue" -- "$ncur" ) )
;;
refresh=*)
COMPREPLY=( $( compgen -W "120 $varvalue" -- "$ncur" ) )
;;
defaultspec=*)
COMPREPLY=( $( compgen -W "/usr/share/abb/spek.skel $varvalue" -- "$ncur" ) )
;;
arch=*)
COMPREPLY=( $( compgen -W "i586,x86_64 i586 x86_64 $varvalue" -- "$ncur" ) )
;;
platform=*)
varvalue1="$(abb vars branch)"
varvalue1="${varvalue1[@]##*=}"
varvalue="${varvalue} ${varvalue1}"
COMPREPLY=( $( compgen -W "$varvalue" -- "$ncur" ) )
;;
updatetype=*)
COMPREPLY=( $( compgen -W "$updatetypes $varvalue" -- "$ncur" ) )
;;
publish=*)
COMPREPLY=( $( compgen -W "true false $varvalue" -- "$ncur" ) )
;;
repos=*)
COMPREPLY=( $( compgen -W "main main,contrib $varvalue" -- "$ncur" ) )
;;
reposave=*)
varvalue1="$(abb vars branch)"
varvalue1="${varvalue1[@]##*=}"
varvalue="${varvalue} ${varvalue1}"
COMPREPLY=( $( compgen -W "personal $varvalue" -- "$ncur" ) )
;;
withrequired=*)
COMPREPLY=( $( compgen -W "true false $varvalue" -- "$ncur" ) )
;;
esac
return 0
fi
case "${words[1]}" in
build*)
COMPREPLY=( $( compgen -d -W "$specs" -- "$cur" ) \
$( compgen -W "$opts_build" -- "$cur" ) )
return 0
;;
restore)
COMPREPLY=( $( compgen -d -W "$specs" -- "$cur" ) \
$( compgen -W "$opts_restore" -- "$cur" ) )
return 0
;;
status)
COMPREPLY=( $( compgen -d -W "$specs" -- "$cur" ) \
$( compgen -W "$opts_status" -- "$cur" ) )
return 0
;;
view)
COMPREPLY=( $( compgen -d -W "$specs" -- "$cur" ) \
$( compgen -W "$opts_view" -- "$cur" ) )
return 0
;;
send)
COMPREPLY=( $( compgen -d -W "$specs" -- "$cur" ) \
$( compgen -W "$opts_send" -- "$cur" ) )
return 0
;;
clone)
COMPREPLY=( $( compgen -d -W "$opts_clone" -- "$cur" ) )
return 0
;;
new)
COMPREPLY=( $( compgen -d -W "$opts_new" -- "$cur" ) )
return 0
;;
store)
COMPREPLY=( $( compgen -f -W "$opts_store" -- "$cur" ) )
return 0
;;
publish)
COMPREPLY=( $( compgen -W "$opts_publish" -- "$cur" ) )
return 0
;;
vars)
varvalue=${opts//=/}
COMPREPLY=( $( compgen -W "${varvalue}" -S ' ' -- "$cur" ) )
return 0
;;
esac
}
complete -o nospace -o default -F _abb abb
}