1# bash completion for git-bug -*- shell-script -*-
2
3__git-bug_debug()
4{
5 if [[ -n ${BASH_COMP_DEBUG_FILE} ]]; then
6 echo "$*" >> "${BASH_COMP_DEBUG_FILE}"
7 fi
8}
9
10# Homebrew on Macs have version 1.3 of bash-completion which doesn't include
11# _init_completion. This is a very minimal version of that function.
12__git-bug_init_completion()
13{
14 COMPREPLY=()
15 _get_comp_words_by_ref "$@" cur prev words cword
16}
17
18__git-bug_index_of_word()
19{
20 local w word=$1
21 shift
22 index=0
23 for w in "$@"; do
24 [[ $w = "$word" ]] && return
25 index=$((index+1))
26 done
27 index=-1
28}
29
30__git-bug_contains_word()
31{
32 local w word=$1; shift
33 for w in "$@"; do
34 [[ $w = "$word" ]] && return
35 done
36 return 1
37}
38
39__git-bug_handle_go_custom_completion()
40{
41 __git-bug_debug "${FUNCNAME[0]}: cur is ${cur}, words[*] is ${words[*]}, #words[@] is ${#words[@]}"
42
43 local shellCompDirectiveError=1
44 local shellCompDirectiveNoSpace=2
45 local shellCompDirectiveNoFileComp=4
46 local shellCompDirectiveFilterFileExt=8
47 local shellCompDirectiveFilterDirs=16
48
49 local out requestComp lastParam lastChar comp directive args
50
51 # Prepare the command to request completions for the program.
52 # Calling ${words[0]} instead of directly git-bug allows to handle aliases
53 args=("${words[@]:1}")
54 requestComp="${words[0]} __completeNoDesc ${args[*]}"
55
56 lastParam=${words[$((${#words[@]}-1))]}
57 lastChar=${lastParam:$((${#lastParam}-1)):1}
58 __git-bug_debug "${FUNCNAME[0]}: lastParam ${lastParam}, lastChar ${lastChar}"
59
60 if [ -z "${cur}" ] && [ "${lastChar}" != "=" ]; then
61 # If the last parameter is complete (there is a space following it)
62 # We add an extra empty parameter so we can indicate this to the go method.
63 __git-bug_debug "${FUNCNAME[0]}: Adding extra empty parameter"
64 requestComp="${requestComp} \"\""
65 fi
66
67 __git-bug_debug "${FUNCNAME[0]}: calling ${requestComp}"
68 # Use eval to handle any environment variables and such
69 out=$(eval "${requestComp}" 2>/dev/null)
70
71 # Extract the directive integer at the very end of the output following a colon (:)
72 directive=${out##*:}
73 # Remove the directive
74 out=${out%:*}
75 if [ "${directive}" = "${out}" ]; then
76 # There is not directive specified
77 directive=0
78 fi
79 __git-bug_debug "${FUNCNAME[0]}: the completion directive is: ${directive}"
80 __git-bug_debug "${FUNCNAME[0]}: the completions are: ${out[*]}"
81
82 if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
83 # Error code. No completion.
84 __git-bug_debug "${FUNCNAME[0]}: received error from custom completion go code"
85 return
86 else
87 if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
88 if [[ $(type -t compopt) = "builtin" ]]; then
89 __git-bug_debug "${FUNCNAME[0]}: activating no space"
90 compopt -o nospace
91 fi
92 fi
93 if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
94 if [[ $(type -t compopt) = "builtin" ]]; then
95 __git-bug_debug "${FUNCNAME[0]}: activating no file completion"
96 compopt +o default
97 fi
98 fi
99 fi
100
101 if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
102 # File extension filtering
103 local fullFilter filter filteringCmd
104 # Do not use quotes around the $out variable or else newline
105 # characters will be kept.
106 for filter in ${out[*]}; do
107 fullFilter+="$filter|"
108 done
109
110 filteringCmd="_filedir $fullFilter"
111 __git-bug_debug "File filtering command: $filteringCmd"
112 $filteringCmd
113 elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
114 # File completion for directories only
115 local subDir
116 # Use printf to strip any trailing newline
117 subdir=$(printf "%s" "${out[0]}")
118 if [ -n "$subdir" ]; then
119 __git-bug_debug "Listing directories in $subdir"
120 __git-bug_handle_subdirs_in_dir_flag "$subdir"
121 else
122 __git-bug_debug "Listing directories in ."
123 _filedir -d
124 fi
125 else
126 while IFS='' read -r comp; do
127 COMPREPLY+=("$comp")
128 done < <(compgen -W "${out[*]}" -- "$cur")
129 fi
130}
131
132__git-bug_handle_reply()
133{
134 __git-bug_debug "${FUNCNAME[0]}"
135 local comp
136 case $cur in
137 -*)
138 if [[ $(type -t compopt) = "builtin" ]]; then
139 compopt -o nospace
140 fi
141 local allflags
142 if [ ${#must_have_one_flag[@]} -ne 0 ]; then
143 allflags=("${must_have_one_flag[@]}")
144 else
145 allflags=("${flags[*]} ${two_word_flags[*]}")
146 fi
147 while IFS='' read -r comp; do
148 COMPREPLY+=("$comp")
149 done < <(compgen -W "${allflags[*]}" -- "$cur")
150 if [[ $(type -t compopt) = "builtin" ]]; then
151 [[ "${COMPREPLY[0]}" == *= ]] || compopt +o nospace
152 fi
153
154 # complete after --flag=abc
155 if [[ $cur == *=* ]]; then
156 if [[ $(type -t compopt) = "builtin" ]]; then
157 compopt +o nospace
158 fi
159
160 local index flag
161 flag="${cur%=*}"
162 __git-bug_index_of_word "${flag}" "${flags_with_completion[@]}"
163 COMPREPLY=()
164 if [[ ${index} -ge 0 ]]; then
165 PREFIX=""
166 cur="${cur#*=}"
167 ${flags_completion[${index}]}
168 if [ -n "${ZSH_VERSION}" ]; then
169 # zsh completion needs --flag= prefix
170 eval "COMPREPLY=( \"\${COMPREPLY[@]/#/${flag}=}\" )"
171 fi
172 fi
173 fi
174 return 0;
175 ;;
176 esac
177
178 # check if we are handling a flag with special work handling
179 local index
180 __git-bug_index_of_word "${prev}" "${flags_with_completion[@]}"
181 if [[ ${index} -ge 0 ]]; then
182 ${flags_completion[${index}]}
183 return
184 fi
185
186 # we are parsing a flag and don't have a special handler, no completion
187 if [[ ${cur} != "${words[cword]}" ]]; then
188 return
189 fi
190
191 local completions
192 completions=("${commands[@]}")
193 if [[ ${#must_have_one_noun[@]} -ne 0 ]]; then
194 completions+=("${must_have_one_noun[@]}")
195 elif [[ -n "${has_completion_function}" ]]; then
196 # if a go completion function is provided, defer to that function
197 __git-bug_handle_go_custom_completion
198 fi
199 if [[ ${#must_have_one_flag[@]} -ne 0 ]]; then
200 completions+=("${must_have_one_flag[@]}")
201 fi
202 while IFS='' read -r comp; do
203 COMPREPLY+=("$comp")
204 done < <(compgen -W "${completions[*]}" -- "$cur")
205
206 if [[ ${#COMPREPLY[@]} -eq 0 && ${#noun_aliases[@]} -gt 0 && ${#must_have_one_noun[@]} -ne 0 ]]; then
207 while IFS='' read -r comp; do
208 COMPREPLY+=("$comp")
209 done < <(compgen -W "${noun_aliases[*]}" -- "$cur")
210 fi
211
212 if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
213 if declare -F __git-bug_custom_func >/dev/null; then
214 # try command name qualified custom func
215 __git-bug_custom_func
216 else
217 # otherwise fall back to unqualified for compatibility
218 declare -F __custom_func >/dev/null && __custom_func
219 fi
220 fi
221
222 # available in bash-completion >= 2, not always present on macOS
223 if declare -F __ltrim_colon_completions >/dev/null; then
224 __ltrim_colon_completions "$cur"
225 fi
226
227 # If there is only 1 completion and it is a flag with an = it will be completed
228 # but we don't want a space after the =
229 if [[ "${#COMPREPLY[@]}" -eq "1" ]] && [[ $(type -t compopt) = "builtin" ]] && [[ "${COMPREPLY[0]}" == --*= ]]; then
230 compopt -o nospace
231 fi
232}
233
234# The arguments should be in the form "ext1|ext2|extn"
235__git-bug_handle_filename_extension_flag()
236{
237 local ext="$1"
238 _filedir "@(${ext})"
239}
240
241__git-bug_handle_subdirs_in_dir_flag()
242{
243 local dir="$1"
244 pushd "${dir}" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 || return
245}
246
247__git-bug_handle_flag()
248{
249 __git-bug_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
250
251 # if a command required a flag, and we found it, unset must_have_one_flag()
252 local flagname=${words[c]}
253 local flagvalue
254 # if the word contained an =
255 if [[ ${words[c]} == *"="* ]]; then
256 flagvalue=${flagname#*=} # take in as flagvalue after the =
257 flagname=${flagname%=*} # strip everything after the =
258 flagname="${flagname}=" # but put the = back
259 fi
260 __git-bug_debug "${FUNCNAME[0]}: looking for ${flagname}"
261 if __git-bug_contains_word "${flagname}" "${must_have_one_flag[@]}"; then
262 must_have_one_flag=()
263 fi
264
265 # if you set a flag which only applies to this command, don't show subcommands
266 if __git-bug_contains_word "${flagname}" "${local_nonpersistent_flags[@]}"; then
267 commands=()
268 fi
269
270 # keep flag value with flagname as flaghash
271 # flaghash variable is an associative array which is only supported in bash > 3.
272 if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
273 if [ -n "${flagvalue}" ] ; then
274 flaghash[${flagname}]=${flagvalue}
275 elif [ -n "${words[ $((c+1)) ]}" ] ; then
276 flaghash[${flagname}]=${words[ $((c+1)) ]}
277 else
278 flaghash[${flagname}]="true" # pad "true" for bool flag
279 fi
280 fi
281
282 # skip the argument to a two word flag
283 if [[ ${words[c]} != *"="* ]] && __git-bug_contains_word "${words[c]}" "${two_word_flags[@]}"; then
284 __git-bug_debug "${FUNCNAME[0]}: found a flag ${words[c]}, skip the next argument"
285 c=$((c+1))
286 # if we are looking for a flags value, don't show commands
287 if [[ $c -eq $cword ]]; then
288 commands=()
289 fi
290 fi
291
292 c=$((c+1))
293
294}
295
296__git-bug_handle_noun()
297{
298 __git-bug_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
299
300 if __git-bug_contains_word "${words[c]}" "${must_have_one_noun[@]}"; then
301 must_have_one_noun=()
302 elif __git-bug_contains_word "${words[c]}" "${noun_aliases[@]}"; then
303 must_have_one_noun=()
304 fi
305
306 nouns+=("${words[c]}")
307 c=$((c+1))
308}
309
310__git-bug_handle_command()
311{
312 __git-bug_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
313
314 local next_command
315 if [[ -n ${last_command} ]]; then
316 next_command="_${last_command}_${words[c]//:/__}"
317 else
318 if [[ $c -eq 0 ]]; then
319 next_command="_git-bug_root_command"
320 else
321 next_command="_${words[c]//:/__}"
322 fi
323 fi
324 c=$((c+1))
325 __git-bug_debug "${FUNCNAME[0]}: looking for ${next_command}"
326 declare -F "$next_command" >/dev/null && $next_command
327}
328
329__git-bug_handle_word()
330{
331 if [[ $c -ge $cword ]]; then
332 __git-bug_handle_reply
333 return
334 fi
335 __git-bug_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
336 if [[ "${words[c]}" == -* ]]; then
337 __git-bug_handle_flag
338 elif __git-bug_contains_word "${words[c]}" "${commands[@]}"; then
339 __git-bug_handle_command
340 elif [[ $c -eq 0 ]]; then
341 __git-bug_handle_command
342 elif __git-bug_contains_word "${words[c]}" "${command_aliases[@]}"; then
343 # aliashash variable is an associative array which is only supported in bash > 3.
344 if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
345 words[c]=${aliashash[${words[c]}]}
346 __git-bug_handle_command
347 else
348 __git-bug_handle_noun
349 fi
350 else
351 __git-bug_handle_noun
352 fi
353 __git-bug_handle_word
354}
355
356
357_git_bug() {
358 __start_git-bug "$@"
359}
360
361_git-bug_add()
362{
363 last_command="git-bug_add"
364
365 command_aliases=()
366
367 commands=()
368
369 flags=()
370 two_word_flags=()
371 local_nonpersistent_flags=()
372 flags_with_completion=()
373 flags_completion=()
374
375 flags+=("--title=")
376 two_word_flags+=("--title")
377 two_word_flags+=("-t")
378 local_nonpersistent_flags+=("--title")
379 local_nonpersistent_flags+=("--title=")
380 local_nonpersistent_flags+=("-t")
381 flags+=("--message=")
382 two_word_flags+=("--message")
383 two_word_flags+=("-m")
384 local_nonpersistent_flags+=("--message")
385 local_nonpersistent_flags+=("--message=")
386 local_nonpersistent_flags+=("-m")
387 flags+=("--file=")
388 two_word_flags+=("--file")
389 two_word_flags+=("-F")
390 local_nonpersistent_flags+=("--file")
391 local_nonpersistent_flags+=("--file=")
392 local_nonpersistent_flags+=("-F")
393
394 must_have_one_flag=()
395 must_have_one_noun=()
396 noun_aliases=()
397}
398
399_git-bug_bridge_auth_add-token()
400{
401 last_command="git-bug_bridge_auth_add-token"
402
403 command_aliases=()
404
405 commands=()
406
407 flags=()
408 two_word_flags=()
409 local_nonpersistent_flags=()
410 flags_with_completion=()
411 flags_completion=()
412
413 flags+=("--target=")
414 two_word_flags+=("--target")
415 two_word_flags+=("-t")
416 local_nonpersistent_flags+=("--target")
417 local_nonpersistent_flags+=("--target=")
418 local_nonpersistent_flags+=("-t")
419 flags+=("--login=")
420 two_word_flags+=("--login")
421 two_word_flags+=("-l")
422 local_nonpersistent_flags+=("--login")
423 local_nonpersistent_flags+=("--login=")
424 local_nonpersistent_flags+=("-l")
425 flags+=("--user=")
426 two_word_flags+=("--user")
427 two_word_flags+=("-u")
428 local_nonpersistent_flags+=("--user")
429 local_nonpersistent_flags+=("--user=")
430 local_nonpersistent_flags+=("-u")
431
432 must_have_one_flag=()
433 must_have_one_noun=()
434 noun_aliases=()
435}
436
437_git-bug_bridge_auth_rm()
438{
439 last_command="git-bug_bridge_auth_rm"
440
441 command_aliases=()
442
443 commands=()
444
445 flags=()
446 two_word_flags=()
447 local_nonpersistent_flags=()
448 flags_with_completion=()
449 flags_completion=()
450
451
452 must_have_one_flag=()
453 must_have_one_noun=()
454 noun_aliases=()
455}
456
457_git-bug_bridge_auth_show()
458{
459 last_command="git-bug_bridge_auth_show"
460
461 command_aliases=()
462
463 commands=()
464
465 flags=()
466 two_word_flags=()
467 local_nonpersistent_flags=()
468 flags_with_completion=()
469 flags_completion=()
470
471
472 must_have_one_flag=()
473 must_have_one_noun=()
474 noun_aliases=()
475}
476
477_git-bug_bridge_auth()
478{
479 last_command="git-bug_bridge_auth"
480
481 command_aliases=()
482
483 commands=()
484 commands+=("add-token")
485 commands+=("rm")
486 commands+=("show")
487
488 flags=()
489 two_word_flags=()
490 local_nonpersistent_flags=()
491 flags_with_completion=()
492 flags_completion=()
493
494
495 must_have_one_flag=()
496 must_have_one_noun=()
497 noun_aliases=()
498}
499
500_git-bug_bridge_configure()
501{
502 last_command="git-bug_bridge_configure"
503
504 command_aliases=()
505
506 commands=()
507
508 flags=()
509 two_word_flags=()
510 local_nonpersistent_flags=()
511 flags_with_completion=()
512 flags_completion=()
513
514 flags+=("--name=")
515 two_word_flags+=("--name")
516 two_word_flags+=("-n")
517 local_nonpersistent_flags+=("--name")
518 local_nonpersistent_flags+=("--name=")
519 local_nonpersistent_flags+=("-n")
520 flags+=("--target=")
521 two_word_flags+=("--target")
522 two_word_flags+=("-t")
523 local_nonpersistent_flags+=("--target")
524 local_nonpersistent_flags+=("--target=")
525 local_nonpersistent_flags+=("-t")
526 flags+=("--url=")
527 two_word_flags+=("--url")
528 two_word_flags+=("-u")
529 local_nonpersistent_flags+=("--url")
530 local_nonpersistent_flags+=("--url=")
531 local_nonpersistent_flags+=("-u")
532 flags+=("--base-url=")
533 two_word_flags+=("--base-url")
534 two_word_flags+=("-b")
535 local_nonpersistent_flags+=("--base-url")
536 local_nonpersistent_flags+=("--base-url=")
537 local_nonpersistent_flags+=("-b")
538 flags+=("--login=")
539 two_word_flags+=("--login")
540 two_word_flags+=("-l")
541 local_nonpersistent_flags+=("--login")
542 local_nonpersistent_flags+=("--login=")
543 local_nonpersistent_flags+=("-l")
544 flags+=("--credential=")
545 two_word_flags+=("--credential")
546 two_word_flags+=("-c")
547 local_nonpersistent_flags+=("--credential")
548 local_nonpersistent_flags+=("--credential=")
549 local_nonpersistent_flags+=("-c")
550 flags+=("--token=")
551 two_word_flags+=("--token")
552 local_nonpersistent_flags+=("--token")
553 local_nonpersistent_flags+=("--token=")
554 flags+=("--token-stdin")
555 local_nonpersistent_flags+=("--token-stdin")
556 flags+=("--owner=")
557 two_word_flags+=("--owner")
558 two_word_flags+=("-o")
559 local_nonpersistent_flags+=("--owner")
560 local_nonpersistent_flags+=("--owner=")
561 local_nonpersistent_flags+=("-o")
562 flags+=("--project=")
563 two_word_flags+=("--project")
564 two_word_flags+=("-p")
565 local_nonpersistent_flags+=("--project")
566 local_nonpersistent_flags+=("--project=")
567 local_nonpersistent_flags+=("-p")
568
569 must_have_one_flag=()
570 must_have_one_noun=()
571 noun_aliases=()
572}
573
574_git-bug_bridge_pull()
575{
576 last_command="git-bug_bridge_pull"
577
578 command_aliases=()
579
580 commands=()
581
582 flags=()
583 two_word_flags=()
584 local_nonpersistent_flags=()
585 flags_with_completion=()
586 flags_completion=()
587
588 flags+=("--no-resume")
589 flags+=("-n")
590 local_nonpersistent_flags+=("--no-resume")
591 local_nonpersistent_flags+=("-n")
592 flags+=("--since=")
593 two_word_flags+=("--since")
594 two_word_flags+=("-s")
595 local_nonpersistent_flags+=("--since")
596 local_nonpersistent_flags+=("--since=")
597 local_nonpersistent_flags+=("-s")
598
599 must_have_one_flag=()
600 must_have_one_noun=()
601 noun_aliases=()
602}
603
604_git-bug_bridge_push()
605{
606 last_command="git-bug_bridge_push"
607
608 command_aliases=()
609
610 commands=()
611
612 flags=()
613 two_word_flags=()
614 local_nonpersistent_flags=()
615 flags_with_completion=()
616 flags_completion=()
617
618
619 must_have_one_flag=()
620 must_have_one_noun=()
621 noun_aliases=()
622}
623
624_git-bug_bridge_rm()
625{
626 last_command="git-bug_bridge_rm"
627
628 command_aliases=()
629
630 commands=()
631
632 flags=()
633 two_word_flags=()
634 local_nonpersistent_flags=()
635 flags_with_completion=()
636 flags_completion=()
637
638
639 must_have_one_flag=()
640 must_have_one_noun=()
641 noun_aliases=()
642}
643
644_git-bug_bridge()
645{
646 last_command="git-bug_bridge"
647
648 command_aliases=()
649
650 commands=()
651 commands+=("auth")
652 commands+=("configure")
653 commands+=("pull")
654 commands+=("push")
655 commands+=("rm")
656
657 flags=()
658 two_word_flags=()
659 local_nonpersistent_flags=()
660 flags_with_completion=()
661 flags_completion=()
662
663
664 must_have_one_flag=()
665 must_have_one_noun=()
666 noun_aliases=()
667}
668
669_git-bug_commands()
670{
671 last_command="git-bug_commands"
672
673 command_aliases=()
674
675 commands=()
676
677 flags=()
678 two_word_flags=()
679 local_nonpersistent_flags=()
680 flags_with_completion=()
681 flags_completion=()
682
683 flags+=("--pretty")
684 flags+=("-p")
685 local_nonpersistent_flags+=("--pretty")
686 local_nonpersistent_flags+=("-p")
687
688 must_have_one_flag=()
689 must_have_one_noun=()
690 noun_aliases=()
691}
692
693_git-bug_comment_add()
694{
695 last_command="git-bug_comment_add"
696
697 command_aliases=()
698
699 commands=()
700
701 flags=()
702 two_word_flags=()
703 local_nonpersistent_flags=()
704 flags_with_completion=()
705 flags_completion=()
706
707 flags+=("--file=")
708 two_word_flags+=("--file")
709 two_word_flags+=("-F")
710 local_nonpersistent_flags+=("--file")
711 local_nonpersistent_flags+=("--file=")
712 local_nonpersistent_flags+=("-F")
713 flags+=("--message=")
714 two_word_flags+=("--message")
715 two_word_flags+=("-m")
716 local_nonpersistent_flags+=("--message")
717 local_nonpersistent_flags+=("--message=")
718 local_nonpersistent_flags+=("-m")
719
720 must_have_one_flag=()
721 must_have_one_noun=()
722 noun_aliases=()
723}
724
725_git-bug_comment()
726{
727 last_command="git-bug_comment"
728
729 command_aliases=()
730
731 commands=()
732 commands+=("add")
733
734 flags=()
735 two_word_flags=()
736 local_nonpersistent_flags=()
737 flags_with_completion=()
738 flags_completion=()
739
740
741 must_have_one_flag=()
742 must_have_one_noun=()
743 noun_aliases=()
744}
745
746_git-bug_deselect()
747{
748 last_command="git-bug_deselect"
749
750 command_aliases=()
751
752 commands=()
753
754 flags=()
755 two_word_flags=()
756 local_nonpersistent_flags=()
757 flags_with_completion=()
758 flags_completion=()
759
760
761 must_have_one_flag=()
762 must_have_one_noun=()
763 noun_aliases=()
764}
765
766_git-bug_label_add()
767{
768 last_command="git-bug_label_add"
769
770 command_aliases=()
771
772 commands=()
773
774 flags=()
775 two_word_flags=()
776 local_nonpersistent_flags=()
777 flags_with_completion=()
778 flags_completion=()
779
780
781 must_have_one_flag=()
782 must_have_one_noun=()
783 noun_aliases=()
784}
785
786_git-bug_label_rm()
787{
788 last_command="git-bug_label_rm"
789
790 command_aliases=()
791
792 commands=()
793
794 flags=()
795 two_word_flags=()
796 local_nonpersistent_flags=()
797 flags_with_completion=()
798 flags_completion=()
799
800
801 must_have_one_flag=()
802 must_have_one_noun=()
803 noun_aliases=()
804}
805
806_git-bug_label()
807{
808 last_command="git-bug_label"
809
810 command_aliases=()
811
812 commands=()
813 commands+=("add")
814 commands+=("rm")
815
816 flags=()
817 two_word_flags=()
818 local_nonpersistent_flags=()
819 flags_with_completion=()
820 flags_completion=()
821
822
823 must_have_one_flag=()
824 must_have_one_noun=()
825 noun_aliases=()
826}
827
828_git-bug_ls()
829{
830 last_command="git-bug_ls"
831
832 command_aliases=()
833
834 commands=()
835
836 flags=()
837 two_word_flags=()
838 local_nonpersistent_flags=()
839 flags_with_completion=()
840 flags_completion=()
841
842 flags+=("--status=")
843 two_word_flags+=("--status")
844 two_word_flags+=("-s")
845 local_nonpersistent_flags+=("--status")
846 local_nonpersistent_flags+=("--status=")
847 local_nonpersistent_flags+=("-s")
848 flags+=("--author=")
849 two_word_flags+=("--author")
850 two_word_flags+=("-a")
851 local_nonpersistent_flags+=("--author")
852 local_nonpersistent_flags+=("--author=")
853 local_nonpersistent_flags+=("-a")
854 flags+=("--metadata=")
855 two_word_flags+=("--metadata")
856 two_word_flags+=("-m")
857 local_nonpersistent_flags+=("--metadata")
858 local_nonpersistent_flags+=("--metadata=")
859 local_nonpersistent_flags+=("-m")
860 flags+=("--participant=")
861 two_word_flags+=("--participant")
862 two_word_flags+=("-p")
863 local_nonpersistent_flags+=("--participant")
864 local_nonpersistent_flags+=("--participant=")
865 local_nonpersistent_flags+=("-p")
866 flags+=("--actor=")
867 two_word_flags+=("--actor")
868 two_word_flags+=("-A")
869 local_nonpersistent_flags+=("--actor")
870 local_nonpersistent_flags+=("--actor=")
871 local_nonpersistent_flags+=("-A")
872 flags+=("--label=")
873 two_word_flags+=("--label")
874 two_word_flags+=("-l")
875 local_nonpersistent_flags+=("--label")
876 local_nonpersistent_flags+=("--label=")
877 local_nonpersistent_flags+=("-l")
878 flags+=("--title=")
879 two_word_flags+=("--title")
880 two_word_flags+=("-t")
881 local_nonpersistent_flags+=("--title")
882 local_nonpersistent_flags+=("--title=")
883 local_nonpersistent_flags+=("-t")
884 flags+=("--no=")
885 two_word_flags+=("--no")
886 two_word_flags+=("-n")
887 local_nonpersistent_flags+=("--no")
888 local_nonpersistent_flags+=("--no=")
889 local_nonpersistent_flags+=("-n")
890 flags+=("--by=")
891 two_word_flags+=("--by")
892 two_word_flags+=("-b")
893 local_nonpersistent_flags+=("--by")
894 local_nonpersistent_flags+=("--by=")
895 local_nonpersistent_flags+=("-b")
896 flags+=("--direction=")
897 two_word_flags+=("--direction")
898 two_word_flags+=("-d")
899 local_nonpersistent_flags+=("--direction")
900 local_nonpersistent_flags+=("--direction=")
901 local_nonpersistent_flags+=("-d")
902 flags+=("--format=")
903 two_word_flags+=("--format")
904 two_word_flags+=("-f")
905 local_nonpersistent_flags+=("--format")
906 local_nonpersistent_flags+=("--format=")
907 local_nonpersistent_flags+=("-f")
908
909 must_have_one_flag=()
910 must_have_one_noun=()
911 noun_aliases=()
912}
913
914_git-bug_ls-id()
915{
916 last_command="git-bug_ls-id"
917
918 command_aliases=()
919
920 commands=()
921
922 flags=()
923 two_word_flags=()
924 local_nonpersistent_flags=()
925 flags_with_completion=()
926 flags_completion=()
927
928
929 must_have_one_flag=()
930 must_have_one_noun=()
931 noun_aliases=()
932}
933
934_git-bug_ls-label()
935{
936 last_command="git-bug_ls-label"
937
938 command_aliases=()
939
940 commands=()
941
942 flags=()
943 two_word_flags=()
944 local_nonpersistent_flags=()
945 flags_with_completion=()
946 flags_completion=()
947
948
949 must_have_one_flag=()
950 must_have_one_noun=()
951 noun_aliases=()
952}
953
954_git-bug_pull()
955{
956 last_command="git-bug_pull"
957
958 command_aliases=()
959
960 commands=()
961
962 flags=()
963 two_word_flags=()
964 local_nonpersistent_flags=()
965 flags_with_completion=()
966 flags_completion=()
967
968
969 must_have_one_flag=()
970 must_have_one_noun=()
971 noun_aliases=()
972}
973
974_git-bug_push()
975{
976 last_command="git-bug_push"
977
978 command_aliases=()
979
980 commands=()
981
982 flags=()
983 two_word_flags=()
984 local_nonpersistent_flags=()
985 flags_with_completion=()
986 flags_completion=()
987
988
989 must_have_one_flag=()
990 must_have_one_noun=()
991 noun_aliases=()
992}
993
994_git-bug_rm()
995{
996 last_command="git-bug_rm"
997
998 command_aliases=()
999
1000 commands=()
1001
1002 flags=()
1003 two_word_flags=()
1004 local_nonpersistent_flags=()
1005 flags_with_completion=()
1006 flags_completion=()
1007
1008
1009 must_have_one_flag=()
1010 must_have_one_noun=()
1011 noun_aliases=()
1012}
1013
1014_git-bug_select()
1015{
1016 last_command="git-bug_select"
1017
1018 command_aliases=()
1019
1020 commands=()
1021
1022 flags=()
1023 two_word_flags=()
1024 local_nonpersistent_flags=()
1025 flags_with_completion=()
1026 flags_completion=()
1027
1028
1029 must_have_one_flag=()
1030 must_have_one_noun=()
1031 noun_aliases=()
1032}
1033
1034_git-bug_show()
1035{
1036 last_command="git-bug_show"
1037
1038 command_aliases=()
1039
1040 commands=()
1041
1042 flags=()
1043 two_word_flags=()
1044 local_nonpersistent_flags=()
1045 flags_with_completion=()
1046 flags_completion=()
1047
1048 flags+=("--field=")
1049 two_word_flags+=("--field")
1050 local_nonpersistent_flags+=("--field")
1051 local_nonpersistent_flags+=("--field=")
1052 flags+=("--format=")
1053 two_word_flags+=("--format")
1054 two_word_flags+=("-f")
1055 local_nonpersistent_flags+=("--format")
1056 local_nonpersistent_flags+=("--format=")
1057 local_nonpersistent_flags+=("-f")
1058
1059 must_have_one_flag=()
1060 must_have_one_noun=()
1061 noun_aliases=()
1062}
1063
1064_git-bug_status_close()
1065{
1066 last_command="git-bug_status_close"
1067
1068 command_aliases=()
1069
1070 commands=()
1071
1072 flags=()
1073 two_word_flags=()
1074 local_nonpersistent_flags=()
1075 flags_with_completion=()
1076 flags_completion=()
1077
1078
1079 must_have_one_flag=()
1080 must_have_one_noun=()
1081 noun_aliases=()
1082}
1083
1084_git-bug_status_open()
1085{
1086 last_command="git-bug_status_open"
1087
1088 command_aliases=()
1089
1090 commands=()
1091
1092 flags=()
1093 two_word_flags=()
1094 local_nonpersistent_flags=()
1095 flags_with_completion=()
1096 flags_completion=()
1097
1098
1099 must_have_one_flag=()
1100 must_have_one_noun=()
1101 noun_aliases=()
1102}
1103
1104_git-bug_status()
1105{
1106 last_command="git-bug_status"
1107
1108 command_aliases=()
1109
1110 commands=()
1111 commands+=("close")
1112 commands+=("open")
1113
1114 flags=()
1115 two_word_flags=()
1116 local_nonpersistent_flags=()
1117 flags_with_completion=()
1118 flags_completion=()
1119
1120
1121 must_have_one_flag=()
1122 must_have_one_noun=()
1123 noun_aliases=()
1124}
1125
1126_git-bug_termui()
1127{
1128 last_command="git-bug_termui"
1129
1130 command_aliases=()
1131
1132 commands=()
1133
1134 flags=()
1135 two_word_flags=()
1136 local_nonpersistent_flags=()
1137 flags_with_completion=()
1138 flags_completion=()
1139
1140
1141 must_have_one_flag=()
1142 must_have_one_noun=()
1143 noun_aliases=()
1144}
1145
1146_git-bug_title_edit()
1147{
1148 last_command="git-bug_title_edit"
1149
1150 command_aliases=()
1151
1152 commands=()
1153
1154 flags=()
1155 two_word_flags=()
1156 local_nonpersistent_flags=()
1157 flags_with_completion=()
1158 flags_completion=()
1159
1160 flags+=("--title=")
1161 two_word_flags+=("--title")
1162 two_word_flags+=("-t")
1163 local_nonpersistent_flags+=("--title")
1164 local_nonpersistent_flags+=("--title=")
1165 local_nonpersistent_flags+=("-t")
1166
1167 must_have_one_flag=()
1168 must_have_one_noun=()
1169 noun_aliases=()
1170}
1171
1172_git-bug_title()
1173{
1174 last_command="git-bug_title"
1175
1176 command_aliases=()
1177
1178 commands=()
1179 commands+=("edit")
1180
1181 flags=()
1182 two_word_flags=()
1183 local_nonpersistent_flags=()
1184 flags_with_completion=()
1185 flags_completion=()
1186
1187
1188 must_have_one_flag=()
1189 must_have_one_noun=()
1190 noun_aliases=()
1191}
1192
1193_git-bug_user_adopt()
1194{
1195 last_command="git-bug_user_adopt"
1196
1197 command_aliases=()
1198
1199 commands=()
1200
1201 flags=()
1202 two_word_flags=()
1203 local_nonpersistent_flags=()
1204 flags_with_completion=()
1205 flags_completion=()
1206
1207
1208 must_have_one_flag=()
1209 must_have_one_noun=()
1210 noun_aliases=()
1211}
1212
1213_git-bug_user_create()
1214{
1215 last_command="git-bug_user_create"
1216
1217 command_aliases=()
1218
1219 commands=()
1220
1221 flags=()
1222 two_word_flags=()
1223 local_nonpersistent_flags=()
1224 flags_with_completion=()
1225 flags_completion=()
1226
1227
1228 must_have_one_flag=()
1229 must_have_one_noun=()
1230 noun_aliases=()
1231}
1232
1233_git-bug_user_ls()
1234{
1235 last_command="git-bug_user_ls"
1236
1237 command_aliases=()
1238
1239 commands=()
1240
1241 flags=()
1242 two_word_flags=()
1243 local_nonpersistent_flags=()
1244 flags_with_completion=()
1245 flags_completion=()
1246
1247 flags+=("--format=")
1248 two_word_flags+=("--format")
1249 two_word_flags+=("-f")
1250 local_nonpersistent_flags+=("--format")
1251 local_nonpersistent_flags+=("--format=")
1252 local_nonpersistent_flags+=("-f")
1253
1254 must_have_one_flag=()
1255 must_have_one_noun=()
1256 noun_aliases=()
1257}
1258
1259_git-bug_user()
1260{
1261 last_command="git-bug_user"
1262
1263 command_aliases=()
1264
1265 commands=()
1266 commands+=("adopt")
1267 commands+=("create")
1268 commands+=("ls")
1269
1270 flags=()
1271 two_word_flags=()
1272 local_nonpersistent_flags=()
1273 flags_with_completion=()
1274 flags_completion=()
1275
1276 flags+=("--field=")
1277 two_word_flags+=("--field")
1278 two_word_flags+=("-f")
1279 local_nonpersistent_flags+=("--field")
1280 local_nonpersistent_flags+=("--field=")
1281 local_nonpersistent_flags+=("-f")
1282
1283 must_have_one_flag=()
1284 must_have_one_noun=()
1285 noun_aliases=()
1286}
1287
1288_git-bug_version()
1289{
1290 last_command="git-bug_version"
1291
1292 command_aliases=()
1293
1294 commands=()
1295
1296 flags=()
1297 two_word_flags=()
1298 local_nonpersistent_flags=()
1299 flags_with_completion=()
1300 flags_completion=()
1301
1302 flags+=("--number")
1303 flags+=("-n")
1304 local_nonpersistent_flags+=("--number")
1305 local_nonpersistent_flags+=("-n")
1306 flags+=("--commit")
1307 flags+=("-c")
1308 local_nonpersistent_flags+=("--commit")
1309 local_nonpersistent_flags+=("-c")
1310 flags+=("--all")
1311 flags+=("-a")
1312 local_nonpersistent_flags+=("--all")
1313 local_nonpersistent_flags+=("-a")
1314
1315 must_have_one_flag=()
1316 must_have_one_noun=()
1317 noun_aliases=()
1318}
1319
1320_git-bug_webui()
1321{
1322 last_command="git-bug_webui"
1323
1324 command_aliases=()
1325
1326 commands=()
1327
1328 flags=()
1329 two_word_flags=()
1330 local_nonpersistent_flags=()
1331 flags_with_completion=()
1332 flags_completion=()
1333
1334 flags+=("--host=")
1335 two_word_flags+=("--host")
1336 local_nonpersistent_flags+=("--host")
1337 local_nonpersistent_flags+=("--host=")
1338 flags+=("--open")
1339 local_nonpersistent_flags+=("--open")
1340 flags+=("--no-open")
1341 local_nonpersistent_flags+=("--no-open")
1342 flags+=("--port=")
1343 two_word_flags+=("--port")
1344 two_word_flags+=("-p")
1345 local_nonpersistent_flags+=("--port")
1346 local_nonpersistent_flags+=("--port=")
1347 local_nonpersistent_flags+=("-p")
1348 flags+=("--read-only")
1349 local_nonpersistent_flags+=("--read-only")
1350 flags+=("--query=")
1351 two_word_flags+=("--query")
1352 two_word_flags+=("-q")
1353 local_nonpersistent_flags+=("--query")
1354 local_nonpersistent_flags+=("--query=")
1355 local_nonpersistent_flags+=("-q")
1356
1357 must_have_one_flag=()
1358 must_have_one_noun=()
1359 noun_aliases=()
1360}
1361
1362_git-bug_root_command()
1363{
1364 last_command="git-bug"
1365
1366 command_aliases=()
1367
1368 commands=()
1369 commands+=("add")
1370 commands+=("bridge")
1371 commands+=("commands")
1372 commands+=("comment")
1373 commands+=("deselect")
1374 commands+=("label")
1375 commands+=("ls")
1376 commands+=("ls-id")
1377 commands+=("ls-label")
1378 commands+=("pull")
1379 commands+=("push")
1380 commands+=("rm")
1381 commands+=("select")
1382 commands+=("show")
1383 commands+=("status")
1384 commands+=("termui")
1385 if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
1386 command_aliases+=("tui")
1387 aliashash["tui"]="termui"
1388 fi
1389 commands+=("title")
1390 commands+=("user")
1391 commands+=("version")
1392 commands+=("webui")
1393
1394 flags=()
1395 two_word_flags=()
1396 local_nonpersistent_flags=()
1397 flags_with_completion=()
1398 flags_completion=()
1399
1400
1401 must_have_one_flag=()
1402 must_have_one_noun=()
1403 noun_aliases=()
1404}
1405
1406__start_git-bug()
1407{
1408 local cur prev words cword
1409 declare -A flaghash 2>/dev/null || :
1410 declare -A aliashash 2>/dev/null || :
1411 if declare -F _init_completion >/dev/null 2>&1; then
1412 _init_completion -s || return
1413 else
1414 __git-bug_init_completion -n "=" || return
1415 fi
1416
1417 local c=0
1418 local flags=()
1419 local two_word_flags=()
1420 local local_nonpersistent_flags=()
1421 local flags_with_completion=()
1422 local flags_completion=()
1423 local commands=("git-bug")
1424 local must_have_one_flag=()
1425 local must_have_one_noun=()
1426 local has_completion_function
1427 local last_command
1428 local nouns=()
1429
1430 __git-bug_handle_word
1431}
1432
1433if [[ $(type -t compopt) = "builtin" ]]; then
1434 complete -o default -F __start_git-bug git-bug
1435else
1436 complete -o default -o nospace -F __start_git-bug git-bug
1437fi
1438
1439# ex: ts=4 sw=4 et filetype=sh