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_reply()
40{
41 __git-bug_debug "${FUNCNAME[0]}"
42 case $cur in
43 -*)
44 if [[ $(type -t compopt) = "builtin" ]]; then
45 compopt -o nospace
46 fi
47 local allflags
48 if [ ${#must_have_one_flag[@]} -ne 0 ]; then
49 allflags=("${must_have_one_flag[@]}")
50 else
51 allflags=("${flags[*]} ${two_word_flags[*]}")
52 fi
53 COMPREPLY=( $(compgen -W "${allflags[*]}" -- "$cur") )
54 if [[ $(type -t compopt) = "builtin" ]]; then
55 [[ "${COMPREPLY[0]}" == *= ]] || compopt +o nospace
56 fi
57
58 # complete after --flag=abc
59 if [[ $cur == *=* ]]; then
60 if [[ $(type -t compopt) = "builtin" ]]; then
61 compopt +o nospace
62 fi
63
64 local index flag
65 flag="${cur%=*}"
66 __git-bug_index_of_word "${flag}" "${flags_with_completion[@]}"
67 COMPREPLY=()
68 if [[ ${index} -ge 0 ]]; then
69 PREFIX=""
70 cur="${cur#*=}"
71 ${flags_completion[${index}]}
72 if [ -n "${ZSH_VERSION}" ]; then
73 # zsh completion needs --flag= prefix
74 eval "COMPREPLY=( \"\${COMPREPLY[@]/#/${flag}=}\" )"
75 fi
76 fi
77 fi
78 return 0;
79 ;;
80 esac
81
82 # check if we are handling a flag with special work handling
83 local index
84 __git-bug_index_of_word "${prev}" "${flags_with_completion[@]}"
85 if [[ ${index} -ge 0 ]]; then
86 ${flags_completion[${index}]}
87 return
88 fi
89
90 # we are parsing a flag and don't have a special handler, no completion
91 if [[ ${cur} != "${words[cword]}" ]]; then
92 return
93 fi
94
95 local completions
96 completions=("${commands[@]}")
97 if [[ ${#must_have_one_noun[@]} -ne 0 ]]; then
98 completions=("${must_have_one_noun[@]}")
99 fi
100 if [[ ${#must_have_one_flag[@]} -ne 0 ]]; then
101 completions+=("${must_have_one_flag[@]}")
102 fi
103 COMPREPLY=( $(compgen -W "${completions[*]}" -- "$cur") )
104
105 if [[ ${#COMPREPLY[@]} -eq 0 && ${#noun_aliases[@]} -gt 0 && ${#must_have_one_noun[@]} -ne 0 ]]; then
106 COMPREPLY=( $(compgen -W "${noun_aliases[*]}" -- "$cur") )
107 fi
108
109 if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
110 if declare -F __git-bug_custom_func >/dev/null; then
111 # try command name qualified custom func
112 __git-bug_custom_func
113 else
114 # otherwise fall back to unqualified for compatibility
115 declare -F __custom_func >/dev/null && __custom_func
116 fi
117 fi
118
119 # available in bash-completion >= 2, not always present on macOS
120 if declare -F __ltrim_colon_completions >/dev/null; then
121 __ltrim_colon_completions "$cur"
122 fi
123
124 # If there is only 1 completion and it is a flag with an = it will be completed
125 # but we don't want a space after the =
126 if [[ "${#COMPREPLY[@]}" -eq "1" ]] && [[ $(type -t compopt) = "builtin" ]] && [[ "${COMPREPLY[0]}" == --*= ]]; then
127 compopt -o nospace
128 fi
129}
130
131# The arguments should be in the form "ext1|ext2|extn"
132__git-bug_handle_filename_extension_flag()
133{
134 local ext="$1"
135 _filedir "@(${ext})"
136}
137
138__git-bug_handle_subdirs_in_dir_flag()
139{
140 local dir="$1"
141 pushd "${dir}" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1
142}
143
144__git-bug_handle_flag()
145{
146 __git-bug_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
147
148 # if a command required a flag, and we found it, unset must_have_one_flag()
149 local flagname=${words[c]}
150 local flagvalue
151 # if the word contained an =
152 if [[ ${words[c]} == *"="* ]]; then
153 flagvalue=${flagname#*=} # take in as flagvalue after the =
154 flagname=${flagname%=*} # strip everything after the =
155 flagname="${flagname}=" # but put the = back
156 fi
157 __git-bug_debug "${FUNCNAME[0]}: looking for ${flagname}"
158 if __git-bug_contains_word "${flagname}" "${must_have_one_flag[@]}"; then
159 must_have_one_flag=()
160 fi
161
162 # if you set a flag which only applies to this command, don't show subcommands
163 if __git-bug_contains_word "${flagname}" "${local_nonpersistent_flags[@]}"; then
164 commands=()
165 fi
166
167 # keep flag value with flagname as flaghash
168 # flaghash variable is an associative array which is only supported in bash > 3.
169 if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
170 if [ -n "${flagvalue}" ] ; then
171 flaghash[${flagname}]=${flagvalue}
172 elif [ -n "${words[ $((c+1)) ]}" ] ; then
173 flaghash[${flagname}]=${words[ $((c+1)) ]}
174 else
175 flaghash[${flagname}]="true" # pad "true" for bool flag
176 fi
177 fi
178
179 # skip the argument to a two word flag
180 if [[ ${words[c]} != *"="* ]] && __git-bug_contains_word "${words[c]}" "${two_word_flags[@]}"; then
181 __git-bug_debug "${FUNCNAME[0]}: found a flag ${words[c]}, skip the next argument"
182 c=$((c+1))
183 # if we are looking for a flags value, don't show commands
184 if [[ $c -eq $cword ]]; then
185 commands=()
186 fi
187 fi
188
189 c=$((c+1))
190
191}
192
193__git-bug_handle_noun()
194{
195 __git-bug_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
196
197 if __git-bug_contains_word "${words[c]}" "${must_have_one_noun[@]}"; then
198 must_have_one_noun=()
199 elif __git-bug_contains_word "${words[c]}" "${noun_aliases[@]}"; then
200 must_have_one_noun=()
201 fi
202
203 nouns+=("${words[c]}")
204 c=$((c+1))
205}
206
207__git-bug_handle_command()
208{
209 __git-bug_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
210
211 local next_command
212 if [[ -n ${last_command} ]]; then
213 next_command="_${last_command}_${words[c]//:/__}"
214 else
215 if [[ $c -eq 0 ]]; then
216 next_command="_git-bug_root_command"
217 else
218 next_command="_${words[c]//:/__}"
219 fi
220 fi
221 c=$((c+1))
222 __git-bug_debug "${FUNCNAME[0]}: looking for ${next_command}"
223 declare -F "$next_command" >/dev/null && $next_command
224}
225
226__git-bug_handle_word()
227{
228 if [[ $c -ge $cword ]]; then
229 __git-bug_handle_reply
230 return
231 fi
232 __git-bug_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
233 if [[ "${words[c]}" == -* ]]; then
234 __git-bug_handle_flag
235 elif __git-bug_contains_word "${words[c]}" "${commands[@]}"; then
236 __git-bug_handle_command
237 elif [[ $c -eq 0 ]]; then
238 __git-bug_handle_command
239 elif __git-bug_contains_word "${words[c]}" "${command_aliases[@]}"; then
240 # aliashash variable is an associative array which is only supported in bash > 3.
241 if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
242 words[c]=${aliashash[${words[c]}]}
243 __git-bug_handle_command
244 else
245 __git-bug_handle_noun
246 fi
247 else
248 __git-bug_handle_noun
249 fi
250 __git-bug_handle_word
251}
252
253
254_git_bug() {
255 __start_git-bug "$@"
256}
257
258_git-bug_add()
259{
260 last_command="git-bug_add"
261
262 command_aliases=()
263
264 commands=()
265
266 flags=()
267 two_word_flags=()
268 local_nonpersistent_flags=()
269 flags_with_completion=()
270 flags_completion=()
271
272 flags+=("--title=")
273 two_word_flags+=("--title")
274 two_word_flags+=("-t")
275 local_nonpersistent_flags+=("--title=")
276 flags+=("--message=")
277 two_word_flags+=("--message")
278 two_word_flags+=("-m")
279 local_nonpersistent_flags+=("--message=")
280 flags+=("--file=")
281 two_word_flags+=("--file")
282 two_word_flags+=("-F")
283 local_nonpersistent_flags+=("--file=")
284
285 must_have_one_flag=()
286 must_have_one_noun=()
287 noun_aliases=()
288}
289
290_git-bug_bridge_configure()
291{
292 last_command="git-bug_bridge_configure"
293
294 command_aliases=()
295
296 commands=()
297
298 flags=()
299 two_word_flags=()
300 local_nonpersistent_flags=()
301 flags_with_completion=()
302 flags_completion=()
303
304 flags+=("--name=")
305 two_word_flags+=("--name")
306 two_word_flags+=("-n")
307 local_nonpersistent_flags+=("--name=")
308 flags+=("--target=")
309 two_word_flags+=("--target")
310 two_word_flags+=("-t")
311 local_nonpersistent_flags+=("--target=")
312 flags+=("--url=")
313 two_word_flags+=("--url")
314 two_word_flags+=("-u")
315 local_nonpersistent_flags+=("--url=")
316 flags+=("--owner=")
317 two_word_flags+=("--owner")
318 two_word_flags+=("-o")
319 local_nonpersistent_flags+=("--owner=")
320 flags+=("--token=")
321 two_word_flags+=("--token")
322 two_word_flags+=("-T")
323 local_nonpersistent_flags+=("--token=")
324 flags+=("--token-stdin")
325 local_nonpersistent_flags+=("--token-stdin")
326 flags+=("--project=")
327 two_word_flags+=("--project")
328 two_word_flags+=("-p")
329 local_nonpersistent_flags+=("--project=")
330
331 must_have_one_flag=()
332 must_have_one_noun=()
333 noun_aliases=()
334}
335
336_git-bug_bridge_pull()
337{
338 last_command="git-bug_bridge_pull"
339
340 command_aliases=()
341
342 commands=()
343
344 flags=()
345 two_word_flags=()
346 local_nonpersistent_flags=()
347 flags_with_completion=()
348 flags_completion=()
349
350
351 must_have_one_flag=()
352 must_have_one_noun=()
353 noun_aliases=()
354}
355
356_git-bug_bridge_push()
357{
358 last_command="git-bug_bridge_push"
359
360 command_aliases=()
361
362 commands=()
363
364 flags=()
365 two_word_flags=()
366 local_nonpersistent_flags=()
367 flags_with_completion=()
368 flags_completion=()
369
370
371 must_have_one_flag=()
372 must_have_one_noun=()
373 noun_aliases=()
374}
375
376_git-bug_bridge_rm()
377{
378 last_command="git-bug_bridge_rm"
379
380 command_aliases=()
381
382 commands=()
383
384 flags=()
385 two_word_flags=()
386 local_nonpersistent_flags=()
387 flags_with_completion=()
388 flags_completion=()
389
390
391 must_have_one_flag=()
392 must_have_one_noun=()
393 noun_aliases=()
394}
395
396_git-bug_bridge()
397{
398 last_command="git-bug_bridge"
399
400 command_aliases=()
401
402 commands=()
403 commands+=("configure")
404 commands+=("pull")
405 commands+=("push")
406 commands+=("rm")
407
408 flags=()
409 two_word_flags=()
410 local_nonpersistent_flags=()
411 flags_with_completion=()
412 flags_completion=()
413
414
415 must_have_one_flag=()
416 must_have_one_noun=()
417 noun_aliases=()
418}
419
420_git-bug_commands()
421{
422 last_command="git-bug_commands"
423
424 command_aliases=()
425
426 commands=()
427
428 flags=()
429 two_word_flags=()
430 local_nonpersistent_flags=()
431 flags_with_completion=()
432 flags_completion=()
433
434 flags+=("--pretty")
435 flags+=("-p")
436 local_nonpersistent_flags+=("--pretty")
437
438 must_have_one_flag=()
439 must_have_one_noun=()
440 noun_aliases=()
441}
442
443_git-bug_comment_add()
444{
445 last_command="git-bug_comment_add"
446
447 command_aliases=()
448
449 commands=()
450
451 flags=()
452 two_word_flags=()
453 local_nonpersistent_flags=()
454 flags_with_completion=()
455 flags_completion=()
456
457 flags+=("--file=")
458 two_word_flags+=("--file")
459 two_word_flags+=("-F")
460 local_nonpersistent_flags+=("--file=")
461 flags+=("--message=")
462 two_word_flags+=("--message")
463 two_word_flags+=("-m")
464 local_nonpersistent_flags+=("--message=")
465
466 must_have_one_flag=()
467 must_have_one_noun=()
468 noun_aliases=()
469}
470
471_git-bug_comment()
472{
473 last_command="git-bug_comment"
474
475 command_aliases=()
476
477 commands=()
478 commands+=("add")
479
480 flags=()
481 two_word_flags=()
482 local_nonpersistent_flags=()
483 flags_with_completion=()
484 flags_completion=()
485
486
487 must_have_one_flag=()
488 must_have_one_noun=()
489 noun_aliases=()
490}
491
492_git-bug_deselect()
493{
494 last_command="git-bug_deselect"
495
496 command_aliases=()
497
498 commands=()
499
500 flags=()
501 two_word_flags=()
502 local_nonpersistent_flags=()
503 flags_with_completion=()
504 flags_completion=()
505
506
507 must_have_one_flag=()
508 must_have_one_noun=()
509 noun_aliases=()
510}
511
512_git-bug_label_add()
513{
514 last_command="git-bug_label_add"
515
516 command_aliases=()
517
518 commands=()
519
520 flags=()
521 two_word_flags=()
522 local_nonpersistent_flags=()
523 flags_with_completion=()
524 flags_completion=()
525
526
527 must_have_one_flag=()
528 must_have_one_noun=()
529 noun_aliases=()
530}
531
532_git-bug_label_rm()
533{
534 last_command="git-bug_label_rm"
535
536 command_aliases=()
537
538 commands=()
539
540 flags=()
541 two_word_flags=()
542 local_nonpersistent_flags=()
543 flags_with_completion=()
544 flags_completion=()
545
546
547 must_have_one_flag=()
548 must_have_one_noun=()
549 noun_aliases=()
550}
551
552_git-bug_label()
553{
554 last_command="git-bug_label"
555
556 command_aliases=()
557
558 commands=()
559 commands+=("add")
560 commands+=("rm")
561
562 flags=()
563 two_word_flags=()
564 local_nonpersistent_flags=()
565 flags_with_completion=()
566 flags_completion=()
567
568
569 must_have_one_flag=()
570 must_have_one_noun=()
571 noun_aliases=()
572}
573
574_git-bug_ls()
575{
576 last_command="git-bug_ls"
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+=("--status=")
589 two_word_flags+=("--status")
590 two_word_flags+=("-s")
591 local_nonpersistent_flags+=("--status=")
592 flags+=("--author=")
593 two_word_flags+=("--author")
594 two_word_flags+=("-a")
595 local_nonpersistent_flags+=("--author=")
596 flags+=("--participant=")
597 two_word_flags+=("--participant")
598 two_word_flags+=("-p")
599 local_nonpersistent_flags+=("--participant=")
600 flags+=("--actor=")
601 two_word_flags+=("--actor")
602 two_word_flags+=("-A")
603 local_nonpersistent_flags+=("--actor=")
604 flags+=("--label=")
605 two_word_flags+=("--label")
606 two_word_flags+=("-l")
607 local_nonpersistent_flags+=("--label=")
608 flags+=("--title=")
609 two_word_flags+=("--title")
610 two_word_flags+=("-t")
611 local_nonpersistent_flags+=("--title=")
612 flags+=("--no=")
613 two_word_flags+=("--no")
614 two_word_flags+=("-n")
615 local_nonpersistent_flags+=("--no=")
616 flags+=("--by=")
617 two_word_flags+=("--by")
618 two_word_flags+=("-b")
619 local_nonpersistent_flags+=("--by=")
620 flags+=("--direction=")
621 two_word_flags+=("--direction")
622 two_word_flags+=("-d")
623 local_nonpersistent_flags+=("--direction=")
624
625 must_have_one_flag=()
626 must_have_one_noun=()
627 noun_aliases=()
628}
629
630_git-bug_ls-id()
631{
632 last_command="git-bug_ls-id"
633
634 command_aliases=()
635
636 commands=()
637
638 flags=()
639 two_word_flags=()
640 local_nonpersistent_flags=()
641 flags_with_completion=()
642 flags_completion=()
643
644
645 must_have_one_flag=()
646 must_have_one_noun=()
647 noun_aliases=()
648}
649
650_git-bug_ls-label()
651{
652 last_command="git-bug_ls-label"
653
654 command_aliases=()
655
656 commands=()
657
658 flags=()
659 two_word_flags=()
660 local_nonpersistent_flags=()
661 flags_with_completion=()
662 flags_completion=()
663
664
665 must_have_one_flag=()
666 must_have_one_noun=()
667 noun_aliases=()
668}
669
670_git-bug_pull()
671{
672 last_command="git-bug_pull"
673
674 command_aliases=()
675
676 commands=()
677
678 flags=()
679 two_word_flags=()
680 local_nonpersistent_flags=()
681 flags_with_completion=()
682 flags_completion=()
683
684
685 must_have_one_flag=()
686 must_have_one_noun=()
687 noun_aliases=()
688}
689
690_git-bug_push()
691{
692 last_command="git-bug_push"
693
694 command_aliases=()
695
696 commands=()
697
698 flags=()
699 two_word_flags=()
700 local_nonpersistent_flags=()
701 flags_with_completion=()
702 flags_completion=()
703
704
705 must_have_one_flag=()
706 must_have_one_noun=()
707 noun_aliases=()
708}
709
710_git-bug_select()
711{
712 last_command="git-bug_select"
713
714 command_aliases=()
715
716 commands=()
717
718 flags=()
719 two_word_flags=()
720 local_nonpersistent_flags=()
721 flags_with_completion=()
722 flags_completion=()
723
724
725 must_have_one_flag=()
726 must_have_one_noun=()
727 noun_aliases=()
728}
729
730_git-bug_show()
731{
732 last_command="git-bug_show"
733
734 command_aliases=()
735
736 commands=()
737
738 flags=()
739 two_word_flags=()
740 local_nonpersistent_flags=()
741 flags_with_completion=()
742 flags_completion=()
743
744 flags+=("--field=")
745 two_word_flags+=("--field")
746 two_word_flags+=("-f")
747 local_nonpersistent_flags+=("--field=")
748
749 must_have_one_flag=()
750 must_have_one_noun=()
751 noun_aliases=()
752}
753
754_git-bug_status_close()
755{
756 last_command="git-bug_status_close"
757
758 command_aliases=()
759
760 commands=()
761
762 flags=()
763 two_word_flags=()
764 local_nonpersistent_flags=()
765 flags_with_completion=()
766 flags_completion=()
767
768
769 must_have_one_flag=()
770 must_have_one_noun=()
771 noun_aliases=()
772}
773
774_git-bug_status_open()
775{
776 last_command="git-bug_status_open"
777
778 command_aliases=()
779
780 commands=()
781
782 flags=()
783 two_word_flags=()
784 local_nonpersistent_flags=()
785 flags_with_completion=()
786 flags_completion=()
787
788
789 must_have_one_flag=()
790 must_have_one_noun=()
791 noun_aliases=()
792}
793
794_git-bug_status()
795{
796 last_command="git-bug_status"
797
798 command_aliases=()
799
800 commands=()
801 commands+=("close")
802 commands+=("open")
803
804 flags=()
805 two_word_flags=()
806 local_nonpersistent_flags=()
807 flags_with_completion=()
808 flags_completion=()
809
810
811 must_have_one_flag=()
812 must_have_one_noun=()
813 noun_aliases=()
814}
815
816_git-bug_termui()
817{
818 last_command="git-bug_termui"
819
820 command_aliases=()
821
822 commands=()
823
824 flags=()
825 two_word_flags=()
826 local_nonpersistent_flags=()
827 flags_with_completion=()
828 flags_completion=()
829
830
831 must_have_one_flag=()
832 must_have_one_noun=()
833 noun_aliases=()
834}
835
836_git-bug_title_edit()
837{
838 last_command="git-bug_title_edit"
839
840 command_aliases=()
841
842 commands=()
843
844 flags=()
845 two_word_flags=()
846 local_nonpersistent_flags=()
847 flags_with_completion=()
848 flags_completion=()
849
850 flags+=("--title=")
851 two_word_flags+=("--title")
852 two_word_flags+=("-t")
853 local_nonpersistent_flags+=("--title=")
854
855 must_have_one_flag=()
856 must_have_one_noun=()
857 noun_aliases=()
858}
859
860_git-bug_title()
861{
862 last_command="git-bug_title"
863
864 command_aliases=()
865
866 commands=()
867 commands+=("edit")
868
869 flags=()
870 two_word_flags=()
871 local_nonpersistent_flags=()
872 flags_with_completion=()
873 flags_completion=()
874
875
876 must_have_one_flag=()
877 must_have_one_noun=()
878 noun_aliases=()
879}
880
881_git-bug_user_adopt()
882{
883 last_command="git-bug_user_adopt"
884
885 command_aliases=()
886
887 commands=()
888
889 flags=()
890 two_word_flags=()
891 local_nonpersistent_flags=()
892 flags_with_completion=()
893 flags_completion=()
894
895
896 must_have_one_flag=()
897 must_have_one_noun=()
898 noun_aliases=()
899}
900
901_git-bug_user_create()
902{
903 last_command="git-bug_user_create"
904
905 command_aliases=()
906
907 commands=()
908
909 flags=()
910 two_word_flags=()
911 local_nonpersistent_flags=()
912 flags_with_completion=()
913 flags_completion=()
914
915
916 must_have_one_flag=()
917 must_have_one_noun=()
918 noun_aliases=()
919}
920
921_git-bug_user_ls()
922{
923 last_command="git-bug_user_ls"
924
925 command_aliases=()
926
927 commands=()
928
929 flags=()
930 two_word_flags=()
931 local_nonpersistent_flags=()
932 flags_with_completion=()
933 flags_completion=()
934
935
936 must_have_one_flag=()
937 must_have_one_noun=()
938 noun_aliases=()
939}
940
941_git-bug_user()
942{
943 last_command="git-bug_user"
944
945 command_aliases=()
946
947 commands=()
948 commands+=("adopt")
949 commands+=("create")
950 commands+=("ls")
951
952 flags=()
953 two_word_flags=()
954 local_nonpersistent_flags=()
955 flags_with_completion=()
956 flags_completion=()
957
958 flags+=("--field=")
959 two_word_flags+=("--field")
960 two_word_flags+=("-f")
961 local_nonpersistent_flags+=("--field=")
962
963 must_have_one_flag=()
964 must_have_one_noun=()
965 noun_aliases=()
966}
967
968_git-bug_version()
969{
970 last_command="git-bug_version"
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 flags+=("--number")
983 flags+=("-n")
984 local_nonpersistent_flags+=("--number")
985 flags+=("--commit")
986 flags+=("-c")
987 local_nonpersistent_flags+=("--commit")
988 flags+=("--all")
989 flags+=("-a")
990 local_nonpersistent_flags+=("--all")
991
992 must_have_one_flag=()
993 must_have_one_noun=()
994 noun_aliases=()
995}
996
997_git-bug_webui()
998{
999 last_command="git-bug_webui"
1000
1001 command_aliases=()
1002
1003 commands=()
1004
1005 flags=()
1006 two_word_flags=()
1007 local_nonpersistent_flags=()
1008 flags_with_completion=()
1009 flags_completion=()
1010
1011 flags+=("--open")
1012 local_nonpersistent_flags+=("--open")
1013 flags+=("--no-open")
1014 local_nonpersistent_flags+=("--no-open")
1015 flags+=("--port=")
1016 two_word_flags+=("--port")
1017 two_word_flags+=("-p")
1018 local_nonpersistent_flags+=("--port=")
1019
1020 must_have_one_flag=()
1021 must_have_one_noun=()
1022 noun_aliases=()
1023}
1024
1025_git-bug_root_command()
1026{
1027 last_command="git-bug"
1028
1029 command_aliases=()
1030
1031 commands=()
1032 commands+=("add")
1033 commands+=("bridge")
1034 commands+=("commands")
1035 commands+=("comment")
1036 commands+=("deselect")
1037 commands+=("label")
1038 commands+=("ls")
1039 commands+=("ls-id")
1040 commands+=("ls-label")
1041 commands+=("pull")
1042 commands+=("push")
1043 commands+=("select")
1044 commands+=("show")
1045 commands+=("status")
1046 commands+=("termui")
1047 if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
1048 command_aliases+=("tui")
1049 aliashash["tui"]="termui"
1050 fi
1051 commands+=("title")
1052 commands+=("user")
1053 commands+=("version")
1054 commands+=("webui")
1055
1056 flags=()
1057 two_word_flags=()
1058 local_nonpersistent_flags=()
1059 flags_with_completion=()
1060 flags_completion=()
1061
1062
1063 must_have_one_flag=()
1064 must_have_one_noun=()
1065 noun_aliases=()
1066}
1067
1068__start_git-bug()
1069{
1070 local cur prev words cword
1071 declare -A flaghash 2>/dev/null || :
1072 declare -A aliashash 2>/dev/null || :
1073 if declare -F _init_completion >/dev/null 2>&1; then
1074 _init_completion -s || return
1075 else
1076 __git-bug_init_completion -n "=" || return
1077 fi
1078
1079 local c=0
1080 local flags=()
1081 local two_word_flags=()
1082 local local_nonpersistent_flags=()
1083 local flags_with_completion=()
1084 local flags_completion=()
1085 local commands=("git-bug")
1086 local must_have_one_flag=()
1087 local must_have_one_noun=()
1088 local last_command
1089 local nouns=()
1090
1091 __git-bug_handle_word
1092}
1093
1094if [[ $(type -t compopt) = "builtin" ]]; then
1095 complete -o default -F __start_git-bug git-bug
1096else
1097 complete -o default -o nospace -F __start_git-bug git-bug
1098fi
1099
1100# ex: ts=4 sw=4 et filetype=sh