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