git-bug

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