1#compdef _git-bug git-bug
2
3
4function _git-bug {
5 local -a commands
6
7 _arguments -C \
8 "1: :->cmnds" \
9 "*::arg:->args"
10
11 case $state in
12 cmnds)
13 commands=(
14 "add:Create a new bug."
15 "bridge:Configure and use bridges to other bug trackers."
16 "commands:Display available commands."
17 "comment:Display or add comments to a bug."
18 "deselect:Clear the implicitly selected bug."
19 "label:Display, add or remove labels to/from a bug."
20 "ls:List bugs."
21 "ls-id:List bug identifiers."
22 "ls-label:List valid labels."
23 "pull:Pull bugs update from a git remote."
24 "push:Push bugs update to a git remote."
25 "select:Select a bug for implicit use in future commands."
26 "show:Display the details of a bug."
27 "status:Display or change a bug status."
28 "termui:Launch the terminal UI."
29 "title:Display or change a title of a bug."
30 "user:Display or change the user identity."
31 "version:Show git-bug version information."
32 "webui:Launch the web UI."
33 )
34 _describe "command" commands
35 ;;
36 esac
37
38 case "$words[1]" in
39 add)
40 _git-bug_add
41 ;;
42 bridge)
43 _git-bug_bridge
44 ;;
45 commands)
46 _git-bug_commands
47 ;;
48 comment)
49 _git-bug_comment
50 ;;
51 deselect)
52 _git-bug_deselect
53 ;;
54 label)
55 _git-bug_label
56 ;;
57 ls)
58 _git-bug_ls
59 ;;
60 ls-id)
61 _git-bug_ls-id
62 ;;
63 ls-label)
64 _git-bug_ls-label
65 ;;
66 pull)
67 _git-bug_pull
68 ;;
69 push)
70 _git-bug_push
71 ;;
72 select)
73 _git-bug_select
74 ;;
75 show)
76 _git-bug_show
77 ;;
78 status)
79 _git-bug_status
80 ;;
81 termui)
82 _git-bug_termui
83 ;;
84 title)
85 _git-bug_title
86 ;;
87 user)
88 _git-bug_user
89 ;;
90 version)
91 _git-bug_version
92 ;;
93 webui)
94 _git-bug_webui
95 ;;
96 esac
97}
98
99function _git-bug_add {
100 _arguments \
101 '(-t --title)'{-t,--title}'[Provide a title to describe the issue]:' \
102 '(-m --message)'{-m,--message}'[Provide a message to describe the issue]:' \
103 '(-F --file)'{-F,--file}'[Take the message from the given file. Use - to read the message from the standard input]:'
104}
105
106
107function _git-bug_bridge {
108 local -a commands
109
110 _arguments -C \
111 "1: :->cmnds" \
112 "*::arg:->args"
113
114 case $state in
115 cmnds)
116 commands=(
117 "auth:List all known bridge authentication credentials."
118 "configure:Configure a new bridge."
119 "pull:Pull updates."
120 "push:Push updates."
121 "rm:Delete a configured bridge."
122 )
123 _describe "command" commands
124 ;;
125 esac
126
127 case "$words[1]" in
128 auth)
129 _git-bug_bridge_auth
130 ;;
131 configure)
132 _git-bug_bridge_configure
133 ;;
134 pull)
135 _git-bug_bridge_pull
136 ;;
137 push)
138 _git-bug_bridge_push
139 ;;
140 rm)
141 _git-bug_bridge_rm
142 ;;
143 esac
144}
145
146
147function _git-bug_bridge_auth {
148 local -a commands
149
150 _arguments -C \
151 "1: :->cmnds" \
152 "*::arg:->args"
153
154 case $state in
155 cmnds)
156 commands=(
157 "add-token:Store a new token"
158 "rm:Remove a credential."
159 "show:Display an authentication credential."
160 )
161 _describe "command" commands
162 ;;
163 esac
164
165 case "$words[1]" in
166 add-token)
167 _git-bug_bridge_auth_add-token
168 ;;
169 rm)
170 _git-bug_bridge_auth_rm
171 ;;
172 show)
173 _git-bug_bridge_auth_show
174 ;;
175 esac
176}
177
178function _git-bug_bridge_auth_add-token {
179 _arguments \
180 '(-t --target)'{-t,--target}'[The target of the bridge. Valid values are [github,gitlab,launchpad-preview]]:' \
181 '(-l --login)'{-l,--login}'[The login in the remote bug-tracker]:' \
182 '(-u --user)'{-u,--user}'[The user to add the token to. Default is the current user]:'
183}
184
185function _git-bug_bridge_auth_rm {
186 _arguments
187}
188
189function _git-bug_bridge_auth_show {
190 _arguments
191}
192
193function _git-bug_bridge_configure {
194 _arguments \
195 '(-n --name)'{-n,--name}'[A distinctive name to identify the bridge]:' \
196 '(-t --target)'{-t,--target}'[The target of the bridge. Valid values are [github,gitlab,launchpad-preview]]:' \
197 '(-u --url)'{-u,--url}'[The URL of the target repository]:' \
198 '(-b --base-url)'{-b,--base-url}'[The base URL of your issue tracker service]:' \
199 '(-o --owner)'{-o,--owner}'[The owner of the target repository]:' \
200 '(-c --credential)'{-c,--credential}'[The identifier or prefix of an already known credential for the API (see "git-bug bridge auth")]:' \
201 '--token[A raw authentication token for the API]:' \
202 '--token-stdin[Will read the token from stdin and ignore --token]' \
203 '(-p --project)'{-p,--project}'[The name of the target repository]:'
204}
205
206function _git-bug_bridge_pull {
207 _arguments \
208 '(-n --no-resume)'{-n,--no-resume}'[force importing all bugs]' \
209 '(-s --since)'{-s,--since}'[import only bugs updated after the given date (ex: "200h" or "june 2 2019")]:'
210}
211
212function _git-bug_bridge_push {
213 _arguments
214}
215
216function _git-bug_bridge_rm {
217 _arguments
218}
219
220function _git-bug_commands {
221 _arguments \
222 '(-p --pretty)'{-p,--pretty}'[Output the command description as well as Markdown compatible comment]'
223}
224
225
226function _git-bug_comment {
227 local -a commands
228
229 _arguments -C \
230 "1: :->cmnds" \
231 "*::arg:->args"
232
233 case $state in
234 cmnds)
235 commands=(
236 "add:Add a new comment to a bug."
237 )
238 _describe "command" commands
239 ;;
240 esac
241
242 case "$words[1]" in
243 add)
244 _git-bug_comment_add
245 ;;
246 esac
247}
248
249function _git-bug_comment_add {
250 _arguments \
251 '(-F --file)'{-F,--file}'[Take the message from the given file. Use - to read the message from the standard input]:' \
252 '(-m --message)'{-m,--message}'[Provide the new message from the command line]:'
253}
254
255function _git-bug_deselect {
256 _arguments
257}
258
259
260function _git-bug_label {
261 local -a commands
262
263 _arguments -C \
264 "1: :->cmnds" \
265 "*::arg:->args"
266
267 case $state in
268 cmnds)
269 commands=(
270 "add:Add a label to a bug."
271 "rm:Remove a label from a bug."
272 )
273 _describe "command" commands
274 ;;
275 esac
276
277 case "$words[1]" in
278 add)
279 _git-bug_label_add
280 ;;
281 rm)
282 _git-bug_label_rm
283 ;;
284 esac
285}
286
287function _git-bug_label_add {
288 _arguments
289}
290
291function _git-bug_label_rm {
292 _arguments
293}
294
295function _git-bug_ls {
296 _arguments \
297 '(*-s *--status)'{\*-s,\*--status}'[Filter by status. Valid values are [open,closed]]:' \
298 '(*-a *--author)'{\*-a,\*--author}'[Filter by author]:' \
299 '(*-p *--participant)'{\*-p,\*--participant}'[Filter by participant]:' \
300 '(*-A *--actor)'{\*-A,\*--actor}'[Filter by actor]:' \
301 '(*-l *--label)'{\*-l,\*--label}'[Filter by label]:' \
302 '(*-t *--title)'{\*-t,\*--title}'[Filter by title]:' \
303 '(*-n *--no)'{\*-n,\*--no}'[Filter by absence of something. Valid values are [label]]:' \
304 '(-b --by)'{-b,--by}'[Sort the results by a characteristic. Valid values are [id,creation,edit]]:' \
305 '(-d --direction)'{-d,--direction}'[Select the sorting direction. Valid values are [asc,desc]]:'
306}
307
308function _git-bug_ls-id {
309 _arguments
310}
311
312function _git-bug_ls-label {
313 _arguments
314}
315
316function _git-bug_pull {
317 _arguments
318}
319
320function _git-bug_push {
321 _arguments
322}
323
324function _git-bug_select {
325 _arguments
326}
327
328function _git-bug_show {
329 _arguments \
330 '(-f --field)'{-f,--field}'[Select field to display. Valid values are [author,authorEmail,createTime,humanId,id,labels,shortId,status,title,actors,participants]]:'
331}
332
333
334function _git-bug_status {
335 local -a commands
336
337 _arguments -C \
338 "1: :->cmnds" \
339 "*::arg:->args"
340
341 case $state in
342 cmnds)
343 commands=(
344 "close:Mark a bug as closed."
345 "open:Mark a bug as open."
346 )
347 _describe "command" commands
348 ;;
349 esac
350
351 case "$words[1]" in
352 close)
353 _git-bug_status_close
354 ;;
355 open)
356 _git-bug_status_open
357 ;;
358 esac
359}
360
361function _git-bug_status_close {
362 _arguments
363}
364
365function _git-bug_status_open {
366 _arguments
367}
368
369function _git-bug_termui {
370 _arguments
371}
372
373
374function _git-bug_title {
375 local -a commands
376
377 _arguments -C \
378 "1: :->cmnds" \
379 "*::arg:->args"
380
381 case $state in
382 cmnds)
383 commands=(
384 "edit:Edit a title of a bug."
385 )
386 _describe "command" commands
387 ;;
388 esac
389
390 case "$words[1]" in
391 edit)
392 _git-bug_title_edit
393 ;;
394 esac
395}
396
397function _git-bug_title_edit {
398 _arguments \
399 '(-t --title)'{-t,--title}'[Provide a title to describe the issue]:'
400}
401
402
403function _git-bug_user {
404 local -a commands
405
406 _arguments -C \
407 '(-f --field)'{-f,--field}'[Select field to display. Valid values are [email,humanId,id,lastModification,lastModificationLamport,login,metadata,name]]:' \
408 "1: :->cmnds" \
409 "*::arg:->args"
410
411 case $state in
412 cmnds)
413 commands=(
414 "adopt:Adopt an existing identity as your own."
415 "create:Create a new identity."
416 "ls:List identities."
417 )
418 _describe "command" commands
419 ;;
420 esac
421
422 case "$words[1]" in
423 adopt)
424 _git-bug_user_adopt
425 ;;
426 create)
427 _git-bug_user_create
428 ;;
429 ls)
430 _git-bug_user_ls
431 ;;
432 esac
433}
434
435function _git-bug_user_adopt {
436 _arguments
437}
438
439function _git-bug_user_create {
440 _arguments
441}
442
443function _git-bug_user_ls {
444 _arguments
445}
446
447function _git-bug_version {
448 _arguments \
449 '(-n --number)'{-n,--number}'[Only show the version number]' \
450 '(-c --commit)'{-c,--commit}'[Only show the commit hash]' \
451 '(-a --all)'{-a,--all}'[Show all version informations]'
452}
453
454function _git-bug_webui {
455 _arguments \
456 '--open[Automatically open the web UI in the default browser]' \
457 '--no-open[Prevent the automatic opening of the web UI in the default browser]' \
458 '(-p --port)'{-p,--port}'[Port to listen to (default is random)]:'
459}
460