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