-
Notifications
You must be signed in to change notification settings - Fork 6
/
bash_autocomplete
232 lines (190 loc) · 4.99 KB
/
bash_autocomplete
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# bash-completion add-on for rpmlint
# http://bash-completion.alioth.debian.org/
__abf_opts()
{
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${@}" -- "${cur}") )
return 0
fi
return 1
}
__abf_get()
{
__abf_opts "--branch --verbose --help"
}
__abf_create()
{
__abf_opts "--branch --no-def-branch --verbose --help"
}
__abf_put()
{
__abf_opts "--verbose --help --message --minimal-file-size --do-not-remove-files"
}
__abf_show()
{
__abf_opts "--project --verbose --help"
shows="build-repos build-platforms save-to-repos save-to-platforms"
if [[ ${cur} != -* ]] ; then
if [[ ${prev} == -* ]] ; then
return 0;
fi
COMPREPLY=( $(compgen -W "${shows}" -- "${cur}") )
return 0
fi
}
__abf_locate()
{
__abf_opts "--project --directory --verbose --help"
actions="update update-recursive"
if [[ ${cur} != -* ]] ; then
if [[ ${prev} == -* ]] ; then
return 0;
fi
COMPREPLY=( $(compgen -W "${actions}" -- "${cur}") )
return 0
fi
}
__abf_mock_urpm()
{
__abf_opts "--config --verbose --help"
configs_dir='/etc/abf/mock-urpm/configs'
if [ ${prev} == -c ] || [ ${prev} == --config ] ; then
COMPREPLY=( $(compgen -W "` ls -1 ${configs_dir}/*.cfg | xargs -l basename | sed s/[.]cfg//g`" -- "${cur}") )
fi
}
__abf_rpmbuild()
{
__abf_opts "--verbose --help --build"
}
__abf_build()
{
__abf_opts "--branch --build-list --tag --commit --target-platform --arch --repository --save-to-repository --auto-publish-status --auto-publish --update-type --skip-spec-check --auto-create-container --no-extra-tests --no-cached-chroot --save-chroot --testing --external-nodes"
update_types="security bugfix enhancement recommended newpackage"
external_nodes_vals="owned everything"
auto_publish_status="none default testing"
if [ ${prev} == -r ] || [ ${prev} == --repository ] ; then
COMPREPLY=( $(compgen -W "`abf show build-repos`" -- "${cur}") )
return 0
fi
if [ ${prev} == -s ] || [ ${prev} == --save-to-repository ] ; then
proj=""
next=0
for i in ${COMP_WORDS[@]}
do
if [[ $next == 1 ]] ; then
proj=$i;
next=0;
fi
if [[ "$i" == "-p" || "$i" == "--project" ]] ; then
next=1;
fi;
done
if [ -n "${proj}" ] ; then
COMPREPLY=( $(compgen -W "`abf show save-to-repos -p ${proj}`" -- "${cur}") )
fi
return 0
fi
if [ ${prev} == --update-type ] ; then
COMPREPLY=( $(compgen -W "${update_types}" -- "${cur}") )
return 0
fi
if [ ${prev} == --external-nodes ] ; then
COMPREPLY=( $(compgen -W "${external_nodes_vals}" -- "${cur}") )
return 0
fi
if [ ${prev} == --auto-publish-status ] ; then
COMPREPLY=( $(compgen -W "${auto_publish_status}" -- "${cur}") )
return 0
fi
}
__abf_chain_build()
{
__abf_opts "--branch --build-list --tag --infile --commit --target-platform --arch --repository --save-to-repository --auto-publish-status --auto-publish --skip-spec-check --auto-create-container --no-extra-tests --no-cached-chroot --testing"
auto_publish_status="none default testing"
if [ ${prev} == --auto-publish-status ] ; then
COMPREPLY=( $(compgen -W "${auto_publish_status}" -- "${cur}") )
return 0
fi
}
__abf_publish()
{
__abf_opts "--verbose --help"
}
__abf_copy()
{
__abf_opts "--pack --verbose --help"
if [[ ${cur} != -* ]] ; then
branches=`git branch --no-color | sed 's/^..//' | xargs echo`
COMPREPLY=( $(compgen -W "${branches}" -- "${cur}") )
return 0
fi
}
__abf_status()
{
__abf_opts "--verbose --help"
}
__abf_help()
{
__abf_opts "--verbose --help"
}
__abf_search()
{
__abf_opts "--verbose --help"
types="users groups platforms projects"
if [ "$COMP_CWORD" == "2" ] ; then
COMPREPLY=( $(compgen -W "${types}" -- "${cur}") )
return 0
fi
}
__abf_test()
{
__abf_opts "--verbose --help"
}
__abf_fetch()
{
__abf_opts "--only --verbose --help"
}
__abf_store()
{
__abf_opts "--verbose --help"
if [ $? == 0 ]
then
return 0;
fi
_filedir
return 0
}
__abf_clean()
{
__abf_opts "--auto-remove --verbose --help"
}
__abf_alias()
{
__abf_opts "--verbose --help"
types="add remove list"
if [ "$COMP_CWORD" == "2" ] ; then
COMPREPLY=( $(compgen -W "${types}" -- "${cur}") )
return 0
fi
}
__abf()
{
local opts modes
modes="help get put show build chain_build publish status locate search test fetch mock-urpm rpmbuild clean copy create store alias add remove fork destroy pullrequest info"
COMPREPLY=()
mode="${COMP_WORDS[1]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
cur="${COMP_WORDS[COMP_CWORD]}"
if [ "$COMP_CWORD" == "1" ] || ( [ "$COMP_CWORD" == "2" ] && [ "$mode" == "help" ] ); then
COMPREPLY=( $(compgen -W "${modes}" -- ${cur}) )
return 0
fi
for i in ${modes}
do
if [[ $i == $mode ]] ; then
j=`echo ${mode}| sed s/-/_/`
eval __abf_${j};
fi
done
}
complete -F __abf abf