aboutsummaryrefslogtreecommitdiffstats
path: root/misc/zsh_completion/git-bug
blob: 4ae1038208c1d7954de0c880733a9637352d4647 (plain) (blame)
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
#compdef _git-bug git-bug


function _git-bug {
  local -a commands

  _arguments -C \
    "1: :->cmnds" \
    "*::arg:->args"

  case $state in
  cmnds)
    commands=(
      "add:Create a new bug."
      "bridge:Configure and use bridges to other bug trackers."
      "commands:Display available commands."
      "comment:Display or add comments to a bug."
      "deselect:Clear the implicitly selected bug."
      "label:Display, add or remove labels to/from a bug."
      "ls:List bugs."
      "ls-id:List bug identifiers."
      "ls-label:List valid labels."
      "pull:Pull bugs update from a git remote."
      "push:Push bugs update to a git remote."
      "rm:Remove an existing bug."
      "select:Select a bug for implicit use in future commands."
      "show:Display the details of a bug."
      "status:Display or change a bug status."
      "termui:Launch the terminal UI."
      "title:Display or change a title of a bug."
      "user:Display or change the user identity."
      "version:Show git-bug version information."
      "webui:Launch the web UI."
    )
    _describe "command" commands
    ;;
  esac

  case "$words[1]" in
  add)
    _git-bug_add
    ;;
  bridge)
    _git-bug_bridge
    ;;
  commands)
    _git-bug_commands
    ;;
  comment)
    _git-bug_comment
    ;;
  deselect)
    _git-bug_deselect
    ;;
  label)
    _git-bug_label
    ;;
  ls)
    _git-bug_ls
    ;;
  ls-id)
    _git-bug_ls-id
    ;;
  ls-label)
    _git-bug_ls-label
    ;;
  pull)
    _git-bug_pull
    ;;
  push)
    _git-bug_push
    ;;
  rm)
    _git-bug_rm
    ;;
  select)
    _git-bug_select
    ;;
  show)
    _git-bug_show
    ;;
  status)
    _git-bug_status
    ;;
  termui)
    _git-bug_termui
    ;;
  title)
    _git-bug_title
    ;;
  user)
    _git-bug_user
    ;;
  version)
    _git-bug_version
    ;;
  webui)
    _git-bug_webui
    ;;
  esac
}

function _git-bug_add {
  _arguments \
    '(-t --title)'{-t,--title}'[Provide a title to describe the issue]:' \
    '(-m --message)'{-m,--message}'[Provide a message to describe the issue]:' \
    '(-F --file)'{-F,--file}'[Take the message from the given file. Use - to read the message from the standard input]:'
}


function _git-bug_bridge {
  local -a commands

  _arguments -C \
    "1: :->cmnds" \
    "*::arg:->args"

  case $state in
  cmnds)
    commands=(
      "auth:List all known bridge authentication credentials."
      "configure:Configure a new bridge."
      "pull:Pull updates."
      "push:Push updates."
      "rm:Delete a configured bridge."
    )
    _describe "command" commands
    ;;
  esac

  case "$words[1]" in
  auth)
    _git-bug_bridge_auth
    ;;
  configure)
    _git-bug_bridge_configure
    ;;
  pull)
    _git-bug_bridge_pull
    ;;
  push)
    _git-bug_bridge_push
    ;;
  rm)
    _git-bug_bridge_rm
    ;;
  esac
}


function _git-bug_bridge_auth {
  local -a commands

  _arguments -C \
    "1: :->cmnds" \
    "*::arg:->args"

  case $state in
  cmnds)
    commands=(
      "add-token:Store a new token"
      "rm:Remove a credential."
      "show:Display an authentication credential."
    )
    _describe "command" commands
    ;;
  esac

  case "$words[1]" in
  add-token)
    _git-bug_bridge_auth_add-token
    ;;
  rm)
    _git-bug_bridge_auth_rm
    ;;
  show)
    _git-bug_bridge_auth_show
    ;;
  esac
}

function _git-bug_bridge_auth_add-token {
  _arguments \
    '(-t --target)'{-t,--target}'[The target of the bridge. Valid values are [github,gitlab,jira,launchpad-preview]]:' \
    '(-l --login)'{-l,--login}'[The login in the remote bug-tracker]:' \
    '(-u --user)'{-u,--user}'[The user to add the token to. Default is the current user]:'
}

function _git-bug_bridge_auth_rm {
  _arguments
}

function _git-bug_bridge_auth_show {
  _arguments
}

function _git-bug_bridge_configure {
  _arguments \
    '(-n --name)'{-n,--name}'[A distinctive name to identify the bridge]:' \
    '(-t --target)'{-t,--target}'[The target of the bridge. Valid values are [github,gitlab,jira,launchpad-preview]]:' \
    '(-u --url)'{-u,--url}'[The URL of the remote repository]:' \
    '(-b --base-url)'{-b,--base-url}'[The base URL of your remote issue tracker]:' \
    '(-l --login)'{-l,--login}'[The login on your remote issue tracker]:' \
    '(-c --credential)'{-c,--credential}'[The identifier or prefix of an already known credential for your remote issue tracker (see "git-bug bridge auth")]:' \
    '--token[A raw authentication token for the remote issue tracker]:' \
    '--token-stdin[Will read the token from stdin and ignore --token]' \
    '(-o --owner)'{-o,--owner}'[The owner of the remote repository]:' \
    '(-p --project)'{-p,--project}'[The name of the remote repository]:'
}

function _git-bug_bridge_pull {
  _arguments \
    '(-n --no-resume)'{-n,--no-resume}'[force importing all bugs]' \
    '(-s --since)'{-s,--since}'[import only bugs updated after the given date (ex: "200h" or "june 2 2019")]:'
}

function _git-bug_bridge_push {
  _arguments
}

function _git-bug_bridge_rm {
  _arguments
}

function _git-bug_commands {
  _arguments \
    '(-p --pretty)'{-p,--pretty}'[Output the command description as well as Markdown compatible comment]'
}


function _git-bug_comment {
  local -a commands

  _arguments -C \
    "1: :->cmnds" \
    "*::arg:->args"

  case $state in
  cmnds)
    commands=(
      "add:Add a new comment to a bug."
    )
    _describe "command" commands
    ;;
  esac

  case "$words[1]" in
  add)
    _git-bug_comment_add
    ;;
  esac
}

function _git-bug_comment_add {
  _arguments \
    '(-F --file)'{-F,--file}'[Take the message from the given file. Use - to read the message from the standard input]:' \
    '(-m --message)'{-m,--message}'[Provide the new message from the command line]:'
}

function _git-bug_deselect {
  _arguments
}


function _git-bug_label {
  local -a commands

  _arguments -C \
    "1: :->cmnds" \
    "*::arg:->args"

  case $state in
  cmnds)
    commands=(
      "add:Add a label to a bug."
      "rm:Remove a label from a bug."
    )
    _describe "command" commands
    ;;
  esac

  case "$words[1]" in
  add)
    _git-bug_label_add
    ;;
  rm)
    _git-bug_label_rm
    ;;
  esac
}

function _git-bug_label_add {
  _arguments
}

function _git-bug_label_rm {
  _arguments
}

function _git-bug_ls {
  _arguments \
    '(*-s *--status)'{\*-s,\*--status}'[Filter by status. Valid values are [open,closed]]:' \
    '(*-a *--author)'{\*-a,\*--author}'[Filter by author]:' \
    '(*-p *--participant)'{\*-p,\*--participant}'[Filter by participant]:' \
    '(*-A *--actor)'{\*-A,\*--actor}'[Filter by actor]:' \
    '(*-l *--label)'{\*-l,\*--label}'[Filter by label]:' \
    '(*-t *--title)'{\*-t,\*--title}'[Filter by title]:' \
    '(*-n *--no)'{\*-n,\*--no}'[Filter by absence of something. Valid values are [label]]:' \
    '(-b --by)'{-b,--by}'[Sort the results by a characteristic. Valid values are [id,creation,edit]]:' \
    '(-d --direction)'{-d,--direction}'[Select the sorting direction. Valid values are [asc,desc]]:' \
    '(-f --format)'{-f,--format}'[Select the output formatting style. Valid values are [default,plain,json,org-mode]]:'
}

function _git-bug_ls-id {
  _arguments
}

function _git-bug_ls-label {
  _arguments
}

function _git-bug_pull {
  _arguments
}

function _git-bug_push {
  _arguments
}

function _git-bug_rm {
  _arguments
}

function _git-bug_select {
  _arguments
}

function _git-bug_show {
  _arguments \
    '--field[Select field to display. Valid values are [author,authorEmail,createTime,lastEdit,humanId,id,labels,shortId,status,title,actors,participants]]:' \
    '(-f --format)'{-f,--format}'[Select the output formatting style. Valid values are [default,json,org-mode]]:'
}


function _git-bug_status {
  local -a commands

  _arguments -C \
    "1: :->cmnds" \
    "*::arg:->args"

  case $state in
  cmnds)
    commands=(
      "close:Mark a bug as closed."
      "open:Mark a bug as open."
    )
    _describe "command" commands
    ;;
  esac

  case "$words[1]" in
  close)
    _git-bug_status_close
    ;;
  open)
    _git-bug_status_open
    ;;
  esac
}

function _git-bug_status_close {
  _arguments
}

function _git-bug_status_open {
  _arguments
}

function _git-bug_termui {
  _arguments
}


function _git-bug_title {
  local -a commands

  _arguments -C \
    "1: :->cmnds" \
    "*::arg:->args"

  case $state in
  cmnds)
    commands=(
      "edit:Edit a title of a bug."
    )
    _describe "command" commands
    ;;
  esac

  case "$words[1]" in
  edit)
    _git-bug_title_edit
    ;;
  esac
}

function _git-bug_title_edit {
  _arguments \
    '(-t --title)'{-t,--title}'[Provide a title to describe the issue]:'
}


function _git-bug_user {
  local -a commands

  _arguments -C \
    '(-f --field)'{-f,--field}'[Select field to display. Valid values are [email,humanId,id,lastModification,lastModificationLamport,login,metadata,name]]:' \
    "1: :->cmnds" \
    "*::arg:->args"

  case $state in
  cmnds)
    commands=(
      "adopt:Adopt an existing identity as your own."
      "create:Create a new identity."
      "ls:List identities."
    )
    _describe "command" commands
    ;;
  esac

  case "$words[1]" in
  adopt)
    _git-bug_user_adopt
    ;;
  create)
    _git-bug_user_create
    ;;
  ls)
    _git-bug_user_ls
    ;;
  esac
}

function _git-bug_user_adopt {
  _arguments
}

function _git-bug_user_create {
  _arguments
}

function _git-bug_user_ls {
  _arguments \
    '(-f --format)'{-f,--format}'[Select the output formatting style. Valid values are [default,json]]:'
}

function _git-bug_version {
  _arguments \
    '(-n --number)'{-n,--number}'[Only show the version number]' \
    '(-c --commit)'{-c,--commit}'[Only show the commit hash]' \
    '(-a --all)'{-a,--all}'[Show all version information]'
}

function _git-bug_webui {
  _arguments \
    '--open[Automatically open the web UI in the default browser]' \
    '--no-open[Prevent the automatic opening of the web UI in the default browser]' \
    '(-p --port)'{-p,--port}'[Port to listen to (default is random)]:' \
    '--read-only[Whether to run the web UI in read-only mode]'
}