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+=("--project=")
325 two_word_flags+=("--project")
326 two_word_flags+=("-p")
327 local_nonpersistent_flags+=("--project=")
328
329 must_have_one_flag=()
330 must_have_one_noun=()
331 noun_aliases=()
332}
333
334_git-bug_bridge_pull()
335{
336 last_command="git-bug_bridge_pull"
337
338 command_aliases=()
339
340 commands=()
341
342 flags=()
343 two_word_flags=()
344 local_nonpersistent_flags=()
345 flags_with_completion=()
346 flags_completion=()
347
348
349 must_have_one_flag=()
350 must_have_one_noun=()
351 noun_aliases=()
352}
353
354_git-bug_bridge_push()
355{
356 last_command="git-bug_bridge_push"
357
358 command_aliases=()
359
360 commands=()
361
362 flags=()
363 two_word_flags=()
364 local_nonpersistent_flags=()
365 flags_with_completion=()
366 flags_completion=()
367
368
369 must_have_one_flag=()
370 must_have_one_noun=()
371 noun_aliases=()
372}
373
374_git-bug_bridge_rm()
375{
376 last_command="git-bug_bridge_rm"
377
378 command_aliases=()
379
380 commands=()
381
382 flags=()
383 two_word_flags=()
384 local_nonpersistent_flags=()
385 flags_with_completion=()
386 flags_completion=()
387
388
389 must_have_one_flag=()
390 must_have_one_noun=()
391 noun_aliases=()
392}
393
394_git-bug_bridge()
395{
396 last_command="git-bug_bridge"
397
398 command_aliases=()
399
400 commands=()
401 commands+=("configure")
402 commands+=("pull")
403 commands+=("push")
404 commands+=("rm")
405
406 flags=()
407 two_word_flags=()
408 local_nonpersistent_flags=()
409 flags_with_completion=()
410 flags_completion=()
411
412
413 must_have_one_flag=()
414 must_have_one_noun=()
415 noun_aliases=()
416}
417
418_git-bug_commands()
419{
420 last_command="git-bug_commands"
421
422 command_aliases=()
423
424 commands=()
425
426 flags=()
427 two_word_flags=()
428 local_nonpersistent_flags=()
429 flags_with_completion=()
430 flags_completion=()
431
432 flags+=("--pretty")
433 flags+=("-p")
434 local_nonpersistent_flags+=("--pretty")
435
436 must_have_one_flag=()
437 must_have_one_noun=()
438 noun_aliases=()
439}
440
441_git-bug_comment_add()
442{
443 last_command="git-bug_comment_add"
444
445 command_aliases=()
446
447 commands=()
448
449 flags=()
450 two_word_flags=()
451 local_nonpersistent_flags=()
452 flags_with_completion=()
453 flags_completion=()
454
455 flags+=("--file=")
456 two_word_flags+=("--file")
457 two_word_flags+=("-F")
458 local_nonpersistent_flags+=("--file=")
459 flags+=("--message=")
460 two_word_flags+=("--message")
461 two_word_flags+=("-m")
462 local_nonpersistent_flags+=("--message=")
463
464 must_have_one_flag=()
465 must_have_one_noun=()
466 noun_aliases=()
467}
468
469_git-bug_comment()
470{
471 last_command="git-bug_comment"
472
473 command_aliases=()
474
475 commands=()
476 commands+=("add")
477
478 flags=()
479 two_word_flags=()
480 local_nonpersistent_flags=()
481 flags_with_completion=()
482 flags_completion=()
483
484
485 must_have_one_flag=()
486 must_have_one_noun=()
487 noun_aliases=()
488}
489
490_git-bug_deselect()
491{
492 last_command="git-bug_deselect"
493
494 command_aliases=()
495
496 commands=()
497
498 flags=()
499 two_word_flags=()
500 local_nonpersistent_flags=()
501 flags_with_completion=()
502 flags_completion=()
503
504
505 must_have_one_flag=()
506 must_have_one_noun=()
507 noun_aliases=()
508}
509
510_git-bug_label_add()
511{
512 last_command="git-bug_label_add"
513
514 command_aliases=()
515
516 commands=()
517
518 flags=()
519 two_word_flags=()
520 local_nonpersistent_flags=()
521 flags_with_completion=()
522 flags_completion=()
523
524
525 must_have_one_flag=()
526 must_have_one_noun=()
527 noun_aliases=()
528}
529
530_git-bug_label_rm()
531{
532 last_command="git-bug_label_rm"
533
534 command_aliases=()
535
536 commands=()
537
538 flags=()
539 two_word_flags=()
540 local_nonpersistent_flags=()
541 flags_with_completion=()
542 flags_completion=()
543
544
545 must_have_one_flag=()
546 must_have_one_noun=()
547 noun_aliases=()
548}
549
550_git-bug_label()
551{
552 last_command="git-bug_label"
553
554 command_aliases=()
555
556 commands=()
557 commands+=("add")
558 commands+=("rm")
559
560 flags=()
561 two_word_flags=()
562 local_nonpersistent_flags=()
563 flags_with_completion=()
564 flags_completion=()
565
566
567 must_have_one_flag=()
568 must_have_one_noun=()
569 noun_aliases=()
570}
571
572_git-bug_ls()
573{
574 last_command="git-bug_ls"
575
576 command_aliases=()
577
578 commands=()
579
580 flags=()
581 two_word_flags=()
582 local_nonpersistent_flags=()
583 flags_with_completion=()
584 flags_completion=()
585
586 flags+=("--status=")
587 two_word_flags+=("--status")
588 two_word_flags+=("-s")
589 local_nonpersistent_flags+=("--status=")
590 flags+=("--author=")
591 two_word_flags+=("--author")
592 two_word_flags+=("-a")
593 local_nonpersistent_flags+=("--author=")
594 flags+=("--participant=")
595 two_word_flags+=("--participant")
596 two_word_flags+=("-p")
597 local_nonpersistent_flags+=("--participant=")
598 flags+=("--actor=")
599 two_word_flags+=("--actor")
600 two_word_flags+=("-A")
601 local_nonpersistent_flags+=("--actor=")
602 flags+=("--label=")
603 two_word_flags+=("--label")
604 two_word_flags+=("-l")
605 local_nonpersistent_flags+=("--label=")
606 flags+=("--title=")
607 two_word_flags+=("--title")
608 two_word_flags+=("-t")
609 local_nonpersistent_flags+=("--title=")
610 flags+=("--no=")
611 two_word_flags+=("--no")
612 two_word_flags+=("-n")
613 local_nonpersistent_flags+=("--no=")
614 flags+=("--by=")
615 two_word_flags+=("--by")
616 two_word_flags+=("-b")
617 local_nonpersistent_flags+=("--by=")
618 flags+=("--direction=")
619 two_word_flags+=("--direction")
620 two_word_flags+=("-d")
621 local_nonpersistent_flags+=("--direction=")
622
623 must_have_one_flag=()
624 must_have_one_noun=()
625 noun_aliases=()
626}
627
628_git-bug_ls-id()
629{
630 last_command="git-bug_ls-id"
631
632 command_aliases=()
633
634 commands=()
635
636 flags=()
637 two_word_flags=()
638 local_nonpersistent_flags=()
639 flags_with_completion=()
640 flags_completion=()
641
642
643 must_have_one_flag=()
644 must_have_one_noun=()
645 noun_aliases=()
646}
647
648_git-bug_ls-label()
649{
650 last_command="git-bug_ls-label"
651
652 command_aliases=()
653
654 commands=()
655
656 flags=()
657 two_word_flags=()
658 local_nonpersistent_flags=()
659 flags_with_completion=()
660 flags_completion=()
661
662
663 must_have_one_flag=()
664 must_have_one_noun=()
665 noun_aliases=()
666}
667
668_git-bug_pull()
669{
670 last_command="git-bug_pull"
671
672 command_aliases=()
673
674 commands=()
675
676 flags=()
677 two_word_flags=()
678 local_nonpersistent_flags=()
679 flags_with_completion=()
680 flags_completion=()
681
682
683 must_have_one_flag=()
684 must_have_one_noun=()
685 noun_aliases=()
686}
687
688_git-bug_push()
689{
690 last_command="git-bug_push"
691
692 command_aliases=()
693
694 commands=()
695
696 flags=()
697 two_word_flags=()
698 local_nonpersistent_flags=()
699 flags_with_completion=()
700 flags_completion=()
701
702
703 must_have_one_flag=()
704 must_have_one_noun=()
705 noun_aliases=()
706}
707
708_git-bug_select()
709{
710 last_command="git-bug_select"
711
712 command_aliases=()
713
714 commands=()
715
716 flags=()
717 two_word_flags=()
718 local_nonpersistent_flags=()
719 flags_with_completion=()
720 flags_completion=()
721
722
723 must_have_one_flag=()
724 must_have_one_noun=()
725 noun_aliases=()
726}
727
728_git-bug_show()
729{
730 last_command="git-bug_show"
731
732 command_aliases=()
733
734 commands=()
735
736 flags=()
737 two_word_flags=()
738 local_nonpersistent_flags=()
739 flags_with_completion=()
740 flags_completion=()
741
742 flags+=("--field=")
743 two_word_flags+=("--field")
744 two_word_flags+=("-f")
745 local_nonpersistent_flags+=("--field=")
746
747 must_have_one_flag=()
748 must_have_one_noun=()
749 noun_aliases=()
750}
751
752_git-bug_status_close()
753{
754 last_command="git-bug_status_close"
755
756 command_aliases=()
757
758 commands=()
759
760 flags=()
761 two_word_flags=()
762 local_nonpersistent_flags=()
763 flags_with_completion=()
764 flags_completion=()
765
766
767 must_have_one_flag=()
768 must_have_one_noun=()
769 noun_aliases=()
770}
771
772_git-bug_status_open()
773{
774 last_command="git-bug_status_open"
775
776 command_aliases=()
777
778 commands=()
779
780 flags=()
781 two_word_flags=()
782 local_nonpersistent_flags=()
783 flags_with_completion=()
784 flags_completion=()
785
786
787 must_have_one_flag=()
788 must_have_one_noun=()
789 noun_aliases=()
790}
791
792_git-bug_status()
793{
794 last_command="git-bug_status"
795
796 command_aliases=()
797
798 commands=()
799 commands+=("close")
800 commands+=("open")
801
802 flags=()
803 two_word_flags=()
804 local_nonpersistent_flags=()
805 flags_with_completion=()
806 flags_completion=()
807
808
809 must_have_one_flag=()
810 must_have_one_noun=()
811 noun_aliases=()
812}
813
814_git-bug_termui()
815{
816 last_command="git-bug_termui"
817
818 command_aliases=()
819
820 commands=()
821
822 flags=()
823 two_word_flags=()
824 local_nonpersistent_flags=()
825 flags_with_completion=()
826 flags_completion=()
827
828
829 must_have_one_flag=()
830 must_have_one_noun=()
831 noun_aliases=()
832}
833
834_git-bug_title_edit()
835{
836 last_command="git-bug_title_edit"
837
838 command_aliases=()
839
840 commands=()
841
842 flags=()
843 two_word_flags=()
844 local_nonpersistent_flags=()
845 flags_with_completion=()
846 flags_completion=()
847
848 flags+=("--title=")
849 two_word_flags+=("--title")
850 two_word_flags+=("-t")
851 local_nonpersistent_flags+=("--title=")
852
853 must_have_one_flag=()
854 must_have_one_noun=()
855 noun_aliases=()
856}
857
858_git-bug_title()
859{
860 last_command="git-bug_title"
861
862 command_aliases=()
863
864 commands=()
865 commands+=("edit")
866
867 flags=()
868 two_word_flags=()
869 local_nonpersistent_flags=()
870 flags_with_completion=()
871 flags_completion=()
872
873
874 must_have_one_flag=()
875 must_have_one_noun=()
876 noun_aliases=()
877}
878
879_git-bug_user_adopt()
880{
881 last_command="git-bug_user_adopt"
882
883 command_aliases=()
884
885 commands=()
886
887 flags=()
888 two_word_flags=()
889 local_nonpersistent_flags=()
890 flags_with_completion=()
891 flags_completion=()
892
893
894 must_have_one_flag=()
895 must_have_one_noun=()
896 noun_aliases=()
897}
898
899_git-bug_user_create()
900{
901 last_command="git-bug_user_create"
902
903 command_aliases=()
904
905 commands=()
906
907 flags=()
908 two_word_flags=()
909 local_nonpersistent_flags=()
910 flags_with_completion=()
911 flags_completion=()
912
913
914 must_have_one_flag=()
915 must_have_one_noun=()
916 noun_aliases=()
917}
918
919_git-bug_user_ls()
920{
921 last_command="git-bug_user_ls"
922
923 command_aliases=()
924
925 commands=()
926
927 flags=()
928 two_word_flags=()
929 local_nonpersistent_flags=()
930 flags_with_completion=()
931 flags_completion=()
932
933
934 must_have_one_flag=()
935 must_have_one_noun=()
936 noun_aliases=()
937}
938
939_git-bug_user()
940{
941 last_command="git-bug_user"
942
943 command_aliases=()
944
945 commands=()
946 commands+=("adopt")
947 commands+=("create")
948 commands+=("ls")
949
950 flags=()
951 two_word_flags=()
952 local_nonpersistent_flags=()
953 flags_with_completion=()
954 flags_completion=()
955
956 flags+=("--field=")
957 two_word_flags+=("--field")
958 two_word_flags+=("-f")
959 local_nonpersistent_flags+=("--field=")
960
961 must_have_one_flag=()
962 must_have_one_noun=()
963 noun_aliases=()
964}
965
966_git-bug_version()
967{
968 last_command="git-bug_version"
969
970 command_aliases=()
971
972 commands=()
973
974 flags=()
975 two_word_flags=()
976 local_nonpersistent_flags=()
977 flags_with_completion=()
978 flags_completion=()
979
980 flags+=("--number")
981 flags+=("-n")
982 local_nonpersistent_flags+=("--number")
983 flags+=("--commit")
984 flags+=("-c")
985 local_nonpersistent_flags+=("--commit")
986 flags+=("--all")
987 flags+=("-a")
988 local_nonpersistent_flags+=("--all")
989
990 must_have_one_flag=()
991 must_have_one_noun=()
992 noun_aliases=()
993}
994
995_git-bug_webui()
996{
997 last_command="git-bug_webui"
998
999 command_aliases=()
1000
1001 commands=()
1002
1003 flags=()
1004 two_word_flags=()
1005 local_nonpersistent_flags=()
1006 flags_with_completion=()
1007 flags_completion=()
1008
1009 flags+=("--open")
1010 local_nonpersistent_flags+=("--open")
1011 flags+=("--no-open")
1012 local_nonpersistent_flags+=("--no-open")
1013 flags+=("--port=")
1014 two_word_flags+=("--port")
1015 two_word_flags+=("-p")
1016 local_nonpersistent_flags+=("--port=")
1017
1018 must_have_one_flag=()
1019 must_have_one_noun=()
1020 noun_aliases=()
1021}
1022
1023_git-bug_root_command()
1024{
1025 last_command="git-bug"
1026
1027 command_aliases=()
1028
1029 commands=()
1030 commands+=("add")
1031 commands+=("bridge")
1032 commands+=("commands")
1033 commands+=("comment")
1034 commands+=("deselect")
1035 commands+=("label")
1036 commands+=("ls")
1037 commands+=("ls-id")
1038 commands+=("ls-label")
1039 commands+=("pull")
1040 commands+=("push")
1041 commands+=("select")
1042 commands+=("show")
1043 commands+=("status")
1044 commands+=("termui")
1045 commands+=("title")
1046 commands+=("user")
1047 commands+=("version")
1048 commands+=("webui")
1049
1050 flags=()
1051 two_word_flags=()
1052 local_nonpersistent_flags=()
1053 flags_with_completion=()
1054 flags_completion=()
1055
1056
1057 must_have_one_flag=()
1058 must_have_one_noun=()
1059 noun_aliases=()
1060}
1061
1062__start_git-bug()
1063{
1064 local cur prev words cword
1065 declare -A flaghash 2>/dev/null || :
1066 declare -A aliashash 2>/dev/null || :
1067 if declare -F _init_completion >/dev/null 2>&1; then
1068 _init_completion -s || return
1069 else
1070 __git-bug_init_completion -n "=" || return
1071 fi
1072
1073 local c=0
1074 local flags=()
1075 local two_word_flags=()
1076 local local_nonpersistent_flags=()
1077 local flags_with_completion=()
1078 local flags_completion=()
1079 local commands=("git-bug")
1080 local must_have_one_flag=()
1081 local must_have_one_noun=()
1082 local last_command
1083 local nouns=()
1084
1085 __git-bug_handle_word
1086}
1087
1088if [[ $(type -t compopt) = "builtin" ]]; then
1089 complete -o default -F __start_git-bug git-bug
1090else
1091 complete -o default -o nospace -F __start_git-bug git-bug
1092fi
1093
1094# ex: ts=4 sw=4 et filetype=sh