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+=("--participant=")
855 two_word_flags+=("--participant")
856 two_word_flags+=("-p")
857 local_nonpersistent_flags+=("--participant")
858 local_nonpersistent_flags+=("--participant=")
859 local_nonpersistent_flags+=("-p")
860 flags+=("--actor=")
861 two_word_flags+=("--actor")
862 two_word_flags+=("-A")
863 local_nonpersistent_flags+=("--actor")
864 local_nonpersistent_flags+=("--actor=")
865 local_nonpersistent_flags+=("-A")
866 flags+=("--label=")
867 two_word_flags+=("--label")
868 two_word_flags+=("-l")
869 local_nonpersistent_flags+=("--label")
870 local_nonpersistent_flags+=("--label=")
871 local_nonpersistent_flags+=("-l")
872 flags+=("--title=")
873 two_word_flags+=("--title")
874 two_word_flags+=("-t")
875 local_nonpersistent_flags+=("--title")
876 local_nonpersistent_flags+=("--title=")
877 local_nonpersistent_flags+=("-t")
878 flags+=("--no=")
879 two_word_flags+=("--no")
880 two_word_flags+=("-n")
881 local_nonpersistent_flags+=("--no")
882 local_nonpersistent_flags+=("--no=")
883 local_nonpersistent_flags+=("-n")
884 flags+=("--by=")
885 two_word_flags+=("--by")
886 two_word_flags+=("-b")
887 local_nonpersistent_flags+=("--by")
888 local_nonpersistent_flags+=("--by=")
889 local_nonpersistent_flags+=("-b")
890 flags+=("--direction=")
891 two_word_flags+=("--direction")
892 two_word_flags+=("-d")
893 local_nonpersistent_flags+=("--direction")
894 local_nonpersistent_flags+=("--direction=")
895 local_nonpersistent_flags+=("-d")
896 flags+=("--format=")
897 two_word_flags+=("--format")
898 two_word_flags+=("-f")
899 local_nonpersistent_flags+=("--format")
900 local_nonpersistent_flags+=("--format=")
901 local_nonpersistent_flags+=("-f")
902
903 must_have_one_flag=()
904 must_have_one_noun=()
905 noun_aliases=()
906}
907
908_git-bug_ls-id()
909{
910 last_command="git-bug_ls-id"
911
912 command_aliases=()
913
914 commands=()
915
916 flags=()
917 two_word_flags=()
918 local_nonpersistent_flags=()
919 flags_with_completion=()
920 flags_completion=()
921
922
923 must_have_one_flag=()
924 must_have_one_noun=()
925 noun_aliases=()
926}
927
928_git-bug_ls-label()
929{
930 last_command="git-bug_ls-label"
931
932 command_aliases=()
933
934 commands=()
935
936 flags=()
937 two_word_flags=()
938 local_nonpersistent_flags=()
939 flags_with_completion=()
940 flags_completion=()
941
942
943 must_have_one_flag=()
944 must_have_one_noun=()
945 noun_aliases=()
946}
947
948_git-bug_pull()
949{
950 last_command="git-bug_pull"
951
952 command_aliases=()
953
954 commands=()
955
956 flags=()
957 two_word_flags=()
958 local_nonpersistent_flags=()
959 flags_with_completion=()
960 flags_completion=()
961
962
963 must_have_one_flag=()
964 must_have_one_noun=()
965 noun_aliases=()
966}
967
968_git-bug_push()
969{
970 last_command="git-bug_push"
971
972 command_aliases=()
973
974 commands=()
975
976 flags=()
977 two_word_flags=()
978 local_nonpersistent_flags=()
979 flags_with_completion=()
980 flags_completion=()
981
982
983 must_have_one_flag=()
984 must_have_one_noun=()
985 noun_aliases=()
986}
987
988_git-bug_rm()
989{
990 last_command="git-bug_rm"
991
992 command_aliases=()
993
994 commands=()
995
996 flags=()
997 two_word_flags=()
998 local_nonpersistent_flags=()
999 flags_with_completion=()
1000 flags_completion=()
1001
1002
1003 must_have_one_flag=()
1004 must_have_one_noun=()
1005 noun_aliases=()
1006}
1007
1008_git-bug_select()
1009{
1010 last_command="git-bug_select"
1011
1012 command_aliases=()
1013
1014 commands=()
1015
1016 flags=()
1017 two_word_flags=()
1018 local_nonpersistent_flags=()
1019 flags_with_completion=()
1020 flags_completion=()
1021
1022
1023 must_have_one_flag=()
1024 must_have_one_noun=()
1025 noun_aliases=()
1026}
1027
1028_git-bug_show()
1029{
1030 last_command="git-bug_show"
1031
1032 command_aliases=()
1033
1034 commands=()
1035
1036 flags=()
1037 two_word_flags=()
1038 local_nonpersistent_flags=()
1039 flags_with_completion=()
1040 flags_completion=()
1041
1042 flags+=("--field=")
1043 two_word_flags+=("--field")
1044 local_nonpersistent_flags+=("--field")
1045 local_nonpersistent_flags+=("--field=")
1046 flags+=("--format=")
1047 two_word_flags+=("--format")
1048 two_word_flags+=("-f")
1049 local_nonpersistent_flags+=("--format")
1050 local_nonpersistent_flags+=("--format=")
1051 local_nonpersistent_flags+=("-f")
1052
1053 must_have_one_flag=()
1054 must_have_one_noun=()
1055 noun_aliases=()
1056}
1057
1058_git-bug_status_close()
1059{
1060 last_command="git-bug_status_close"
1061
1062 command_aliases=()
1063
1064 commands=()
1065
1066 flags=()
1067 two_word_flags=()
1068 local_nonpersistent_flags=()
1069 flags_with_completion=()
1070 flags_completion=()
1071
1072
1073 must_have_one_flag=()
1074 must_have_one_noun=()
1075 noun_aliases=()
1076}
1077
1078_git-bug_status_open()
1079{
1080 last_command="git-bug_status_open"
1081
1082 command_aliases=()
1083
1084 commands=()
1085
1086 flags=()
1087 two_word_flags=()
1088 local_nonpersistent_flags=()
1089 flags_with_completion=()
1090 flags_completion=()
1091
1092
1093 must_have_one_flag=()
1094 must_have_one_noun=()
1095 noun_aliases=()
1096}
1097
1098_git-bug_status()
1099{
1100 last_command="git-bug_status"
1101
1102 command_aliases=()
1103
1104 commands=()
1105 commands+=("close")
1106 commands+=("open")
1107
1108 flags=()
1109 two_word_flags=()
1110 local_nonpersistent_flags=()
1111 flags_with_completion=()
1112 flags_completion=()
1113
1114
1115 must_have_one_flag=()
1116 must_have_one_noun=()
1117 noun_aliases=()
1118}
1119
1120_git-bug_termui()
1121{
1122 last_command="git-bug_termui"
1123
1124 command_aliases=()
1125
1126 commands=()
1127
1128 flags=()
1129 two_word_flags=()
1130 local_nonpersistent_flags=()
1131 flags_with_completion=()
1132 flags_completion=()
1133
1134
1135 must_have_one_flag=()
1136 must_have_one_noun=()
1137 noun_aliases=()
1138}
1139
1140_git-bug_title_edit()
1141{
1142 last_command="git-bug_title_edit"
1143
1144 command_aliases=()
1145
1146 commands=()
1147
1148 flags=()
1149 two_word_flags=()
1150 local_nonpersistent_flags=()
1151 flags_with_completion=()
1152 flags_completion=()
1153
1154 flags+=("--title=")
1155 two_word_flags+=("--title")
1156 two_word_flags+=("-t")
1157 local_nonpersistent_flags+=("--title")
1158 local_nonpersistent_flags+=("--title=")
1159 local_nonpersistent_flags+=("-t")
1160
1161 must_have_one_flag=()
1162 must_have_one_noun=()
1163 noun_aliases=()
1164}
1165
1166_git-bug_title()
1167{
1168 last_command="git-bug_title"
1169
1170 command_aliases=()
1171
1172 commands=()
1173 commands+=("edit")
1174
1175 flags=()
1176 two_word_flags=()
1177 local_nonpersistent_flags=()
1178 flags_with_completion=()
1179 flags_completion=()
1180
1181
1182 must_have_one_flag=()
1183 must_have_one_noun=()
1184 noun_aliases=()
1185}
1186
1187_git-bug_user_adopt()
1188{
1189 last_command="git-bug_user_adopt"
1190
1191 command_aliases=()
1192
1193 commands=()
1194
1195 flags=()
1196 two_word_flags=()
1197 local_nonpersistent_flags=()
1198 flags_with_completion=()
1199 flags_completion=()
1200
1201
1202 must_have_one_flag=()
1203 must_have_one_noun=()
1204 noun_aliases=()
1205}
1206
1207_git-bug_user_create()
1208{
1209 last_command="git-bug_user_create"
1210
1211 command_aliases=()
1212
1213 commands=()
1214
1215 flags=()
1216 two_word_flags=()
1217 local_nonpersistent_flags=()
1218 flags_with_completion=()
1219 flags_completion=()
1220
1221
1222 must_have_one_flag=()
1223 must_have_one_noun=()
1224 noun_aliases=()
1225}
1226
1227_git-bug_user_ls()
1228{
1229 last_command="git-bug_user_ls"
1230
1231 command_aliases=()
1232
1233 commands=()
1234
1235 flags=()
1236 two_word_flags=()
1237 local_nonpersistent_flags=()
1238 flags_with_completion=()
1239 flags_completion=()
1240
1241 flags+=("--format=")
1242 two_word_flags+=("--format")
1243 two_word_flags+=("-f")
1244 local_nonpersistent_flags+=("--format")
1245 local_nonpersistent_flags+=("--format=")
1246 local_nonpersistent_flags+=("-f")
1247
1248 must_have_one_flag=()
1249 must_have_one_noun=()
1250 noun_aliases=()
1251}
1252
1253_git-bug_user()
1254{
1255 last_command="git-bug_user"
1256
1257 command_aliases=()
1258
1259 commands=()
1260 commands+=("adopt")
1261 commands+=("create")
1262 commands+=("ls")
1263
1264 flags=()
1265 two_word_flags=()
1266 local_nonpersistent_flags=()
1267 flags_with_completion=()
1268 flags_completion=()
1269
1270 flags+=("--field=")
1271 two_word_flags+=("--field")
1272 two_word_flags+=("-f")
1273 local_nonpersistent_flags+=("--field")
1274 local_nonpersistent_flags+=("--field=")
1275 local_nonpersistent_flags+=("-f")
1276
1277 must_have_one_flag=()
1278 must_have_one_noun=()
1279 noun_aliases=()
1280}
1281
1282_git-bug_version()
1283{
1284 last_command="git-bug_version"
1285
1286 command_aliases=()
1287
1288 commands=()
1289
1290 flags=()
1291 two_word_flags=()
1292 local_nonpersistent_flags=()
1293 flags_with_completion=()
1294 flags_completion=()
1295
1296 flags+=("--number")
1297 flags+=("-n")
1298 local_nonpersistent_flags+=("--number")
1299 local_nonpersistent_flags+=("-n")
1300 flags+=("--commit")
1301 flags+=("-c")
1302 local_nonpersistent_flags+=("--commit")
1303 local_nonpersistent_flags+=("-c")
1304 flags+=("--all")
1305 flags+=("-a")
1306 local_nonpersistent_flags+=("--all")
1307 local_nonpersistent_flags+=("-a")
1308
1309 must_have_one_flag=()
1310 must_have_one_noun=()
1311 noun_aliases=()
1312}
1313
1314_git-bug_webui()
1315{
1316 last_command="git-bug_webui"
1317
1318 command_aliases=()
1319
1320 commands=()
1321
1322 flags=()
1323 two_word_flags=()
1324 local_nonpersistent_flags=()
1325 flags_with_completion=()
1326 flags_completion=()
1327
1328 flags+=("--open")
1329 local_nonpersistent_flags+=("--open")
1330 flags+=("--no-open")
1331 local_nonpersistent_flags+=("--no-open")
1332 flags+=("--port=")
1333 two_word_flags+=("--port")
1334 two_word_flags+=("-p")
1335 local_nonpersistent_flags+=("--port")
1336 local_nonpersistent_flags+=("--port=")
1337 local_nonpersistent_flags+=("-p")
1338 flags+=("--read-only")
1339 local_nonpersistent_flags+=("--read-only")
1340
1341 must_have_one_flag=()
1342 must_have_one_noun=()
1343 noun_aliases=()
1344}
1345
1346_git-bug_root_command()
1347{
1348 last_command="git-bug"
1349
1350 command_aliases=()
1351
1352 commands=()
1353 commands+=("add")
1354 commands+=("bridge")
1355 commands+=("commands")
1356 commands+=("comment")
1357 commands+=("deselect")
1358 commands+=("label")
1359 commands+=("ls")
1360 commands+=("ls-id")
1361 commands+=("ls-label")
1362 commands+=("pull")
1363 commands+=("push")
1364 commands+=("rm")
1365 commands+=("select")
1366 commands+=("show")
1367 commands+=("status")
1368 commands+=("termui")
1369 if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
1370 command_aliases+=("tui")
1371 aliashash["tui"]="termui"
1372 fi
1373 commands+=("title")
1374 commands+=("user")
1375 commands+=("version")
1376 commands+=("webui")
1377
1378 flags=()
1379 two_word_flags=()
1380 local_nonpersistent_flags=()
1381 flags_with_completion=()
1382 flags_completion=()
1383
1384
1385 must_have_one_flag=()
1386 must_have_one_noun=()
1387 noun_aliases=()
1388}
1389
1390__start_git-bug()
1391{
1392 local cur prev words cword
1393 declare -A flaghash 2>/dev/null || :
1394 declare -A aliashash 2>/dev/null || :
1395 if declare -F _init_completion >/dev/null 2>&1; then
1396 _init_completion -s || return
1397 else
1398 __git-bug_init_completion -n "=" || return
1399 fi
1400
1401 local c=0
1402 local flags=()
1403 local two_word_flags=()
1404 local local_nonpersistent_flags=()
1405 local flags_with_completion=()
1406 local flags_completion=()
1407 local commands=("git-bug")
1408 local must_have_one_flag=()
1409 local must_have_one_noun=()
1410 local has_completion_function
1411 local last_command
1412 local nouns=()
1413
1414 __git-bug_handle_word
1415}
1416
1417if [[ $(type -t compopt) = "builtin" ]]; then
1418 complete -o default -F __start_git-bug git-bug
1419else
1420 complete -o default -o nospace -F __start_git-bug git-bug
1421fi
1422
1423# ex: ts=4 sw=4 et filetype=sh