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,jira,launchpad-preview]]:'
181}
182
183function _git-bug_bridge_auth_rm {
184 _arguments
185}
186
187function _git-bug_bridge_auth_show {
188 _arguments
189}
190
191function _git-bug_bridge_configure {
192 _arguments \
193 '(-n --name)'{-n,--name}'[A distinctive name to identify the bridge]:' \
194 '(-t --target)'{-t,--target}'[The target of the bridge. Valid values are [github,gitlab,jira,launchpad-preview]]:' \
195 '(-u --url)'{-u,--url}'[The URL of the target repository]:' \
196 '(-b --base-url)'{-b,--base-url}'[The base URL of your issue tracker service]:' \
197 '(-o --owner)'{-o,--owner}'[The owner of the target repository]:' \
198 '(-c --credential)'{-c,--credential}'[The identifier or prefix of an already known credential for the API (see "git-bug bridge auth")]:' \
199 '--token[A raw authentication token for the API]:' \
200 '--token-stdin[Will read the token from stdin and ignore --token]' \
201 '(-p --project)'{-p,--project}'[The name of the target repository]:'
202}
203
204function _git-bug_bridge_pull {
205 _arguments \
206 '(-n --no-resume)'{-n,--no-resume}'[force importing all bugs]' \
207 '(-s --since)'{-s,--since}'[import only bugs updated after the given date (ex: "200h" or "june 2 2019")]:'
208}
209
210function _git-bug_bridge_push {
211 _arguments
212}
213
214function _git-bug_bridge_rm {
215 _arguments
216}
217
218function _git-bug_commands {
219 _arguments \
220 '(-p --pretty)'{-p,--pretty}'[Output the command description as well as Markdown compatible comment]'
221}
222
223
224function _git-bug_comment {
225 local -a commands
226
227 _arguments -C \
228 "1: :->cmnds" \
229 "*::arg:->args"
230
231 case $state in
232 cmnds)
233 commands=(
234 "add:Add a new comment to a bug."
235 )
236 _describe "command" commands
237 ;;
238 esac
239
240 case "$words[1]" in
241 add)
242 _git-bug_comment_add
243 ;;
244 esac
245}
246
247function _git-bug_comment_add {
248 _arguments \
249 '(-F --file)'{-F,--file}'[Take the message from the given file. Use - to read the message from the standard input]:' \
250 '(-m --message)'{-m,--message}'[Provide the new message from the command line]:'
251}
252
253function _git-bug_deselect {
254 _arguments
255}
256
257
258function _git-bug_label {
259 local -a commands
260
261 _arguments -C \
262 "1: :->cmnds" \
263 "*::arg:->args"
264
265 case $state in
266 cmnds)
267 commands=(
268 "add:Add a label to a bug."
269 "rm:Remove a label from a bug."
270 )
271 _describe "command" commands
272 ;;
273 esac
274
275 case "$words[1]" in
276 add)
277 _git-bug_label_add
278 ;;
279 rm)
280 _git-bug_label_rm
281 ;;
282 esac
283}
284
285function _git-bug_label_add {
286 _arguments
287}
288
289function _git-bug_label_rm {
290 _arguments
291}
292
293function _git-bug_ls {
294 _arguments \
295 '(*-s *--status)'{\*-s,\*--status}'[Filter by status. Valid values are [open,closed]]:' \
296 '(*-a *--author)'{\*-a,\*--author}'[Filter by author]:' \
297 '(*-p *--participant)'{\*-p,\*--participant}'[Filter by participant]:' \
298 '(*-A *--actor)'{\*-A,\*--actor}'[Filter by actor]:' \
299 '(*-l *--label)'{\*-l,\*--label}'[Filter by label]:' \
300 '(*-t *--title)'{\*-t,\*--title}'[Filter by title]:' \
301 '(*-n *--no)'{\*-n,\*--no}'[Filter by absence of something. Valid values are [label]]:' \
302 '(-b --by)'{-b,--by}'[Sort the results by a characteristic. Valid values are [id,creation,edit]]:' \
303 '(-d --direction)'{-d,--direction}'[Select the sorting direction. Valid values are [asc,desc]]:'
304}
305
306function _git-bug_ls-id {
307 _arguments
308}
309
310function _git-bug_ls-label {
311 _arguments
312}
313
314function _git-bug_pull {
315 _arguments
316}
317
318function _git-bug_push {
319 _arguments
320}
321
322function _git-bug_select {
323 _arguments
324}
325
326function _git-bug_show {
327 _arguments \
328 '(-f --field)'{-f,--field}'[Select field to display. Valid values are [author,authorEmail,createTime,humanId,id,labels,shortId,status,title,actors,participants]]:'
329}
330
331
332function _git-bug_status {
333 local -a commands
334
335 _arguments -C \
336 "1: :->cmnds" \
337 "*::arg:->args"
338
339 case $state in
340 cmnds)
341 commands=(
342 "close:Mark a bug as closed."
343 "open:Mark a bug as open."
344 )
345 _describe "command" commands
346 ;;
347 esac
348
349 case "$words[1]" in
350 close)
351 _git-bug_status_close
352 ;;
353 open)
354 _git-bug_status_open
355 ;;
356 esac
357}
358
359function _git-bug_status_close {
360 _arguments
361}
362
363function _git-bug_status_open {
364 _arguments
365}
366
367function _git-bug_termui {
368 _arguments
369}
370
371
372function _git-bug_title {
373 local -a commands
374
375 _arguments -C \
376 "1: :->cmnds" \
377 "*::arg:->args"
378
379 case $state in
380 cmnds)
381 commands=(
382 "edit:Edit a title of a bug."
383 )
384 _describe "command" commands
385 ;;
386 esac
387
388 case "$words[1]" in
389 edit)
390 _git-bug_title_edit
391 ;;
392 esac
393}
394
395function _git-bug_title_edit {
396 _arguments \
397 '(-t --title)'{-t,--title}'[Provide a title to describe the issue]:'
398}
399
400
401function _git-bug_user {
402 local -a commands
403
404 _arguments -C \
405 '(-f --field)'{-f,--field}'[Select field to display. Valid values are [email,humanId,id,lastModification,lastModificationLamport,login,metadata,name]]:' \
406 "1: :->cmnds" \
407 "*::arg:->args"
408
409 case $state in
410 cmnds)
411 commands=(
412 "adopt:Adopt an existing identity as your own."
413 "create:Create a new identity."
414 "ls:List identities."
415 )
416 _describe "command" commands
417 ;;
418 esac
419
420 case "$words[1]" in
421 adopt)
422 _git-bug_user_adopt
423 ;;
424 create)
425 _git-bug_user_create
426 ;;
427 ls)
428 _git-bug_user_ls
429 ;;
430 esac
431}
432
433function _git-bug_user_adopt {
434 _arguments
435}
436
437function _git-bug_user_create {
438 _arguments
439}
440
441function _git-bug_user_ls {
442 _arguments
443}
444
445function _git-bug_version {
446 _arguments \
447 '(-n --number)'{-n,--number}'[Only show the version number]' \
448 '(-c --commit)'{-c,--commit}'[Only show the commit hash]' \
449 '(-a --all)'{-a,--all}'[Show all version informations]'
450}
451
452function _git-bug_webui {
453 _arguments \
454 '--open[Automatically open the web UI in the default browser]' \
455 '--no-open[Prevent the automatic opening of the web UI in the default browser]' \
456 '(-p --port)'{-p,--port}'[Port to listen to (default is random)]:'
457}
458