1# bash completion for git-bug -*- shell-script -*-
2
3__git-bug_debug()
4{
5 if [[ -n ${BASH_COMP_DEBUG_FILE} ]]; then
6 echo "$*" >> "${BASH_COMP_DEBUG_FILE}"
7 fi
8}
9
10# Homebrew on Macs have version 1.3 of bash-completion which doesn't include
11# _init_completion. This is a very minimal version of that function.
12__git-bug_init_completion()
13{
14 COMPREPLY=()
15 _get_comp_words_by_ref "$@" cur prev words cword
16}
17
18__git-bug_index_of_word()
19{
20 local w word=$1
21 shift
22 index=0
23 for w in "$@"; do
24 [[ $w = "$word" ]] && return
25 index=$((index+1))
26 done
27 index=-1
28}
29
30__git-bug_contains_word()
31{
32 local w word=$1; shift
33 for w in "$@"; do
34 [[ $w = "$word" ]] && return
35 done
36 return 1
37}
38
39__git-bug_handle_go_custom_completion()
40{
41 __git-bug_debug "${FUNCNAME[0]}: cur is ${cur}, words[*] is ${words[*]}, #words[@] is ${#words[@]}"
42
43 local out requestComp lastParam lastChar comp directive args
44
45 # Prepare the command to request completions for the program.
46 # Calling ${words[0]} instead of directly git-bug allows to handle aliases
47 args=("${words[@]:1}")
48 requestComp="${words[0]} __completeNoDesc ${args[*]}"
49
50 lastParam=${words[$((${#words[@]}-1))]}
51 lastChar=${lastParam:$((${#lastParam}-1)):1}
52 __git-bug_debug "${FUNCNAME[0]}: lastParam ${lastParam}, lastChar ${lastChar}"
53
54 if [ -z "${cur}" ] && [ "${lastChar}" != "=" ]; then
55 # If the last parameter is complete (there is a space following it)
56 # We add an extra empty parameter so we can indicate this to the go method.
57 __git-bug_debug "${FUNCNAME[0]}: Adding extra empty parameter"
58 requestComp="${requestComp} \"\""
59 fi
60
61 __git-bug_debug "${FUNCNAME[0]}: calling ${requestComp}"
62 # Use eval to handle any environment variables and such
63 out=$(eval "${requestComp}" 2>/dev/null)
64
65 # Extract the directive integer at the very end of the output following a colon (:)
66 directive=${out##*:}
67 # Remove the directive
68 out=${out%:*}
69 if [ "${directive}" = "${out}" ]; then
70 # There is not directive specified
71 directive=0
72 fi
73 __git-bug_debug "${FUNCNAME[0]}: the completion directive is: ${directive}"
74 __git-bug_debug "${FUNCNAME[0]}: the completions are: ${out[*]}"
75
76 if [ $((directive & 1)) -ne 0 ]; then
77 # Error code. No completion.
78 __git-bug_debug "${FUNCNAME[0]}: received error from custom completion go code"
79 return
80 else
81 if [ $((directive & 2)) -ne 0 ]; then
82 if [[ $(type -t compopt) = "builtin" ]]; then
83 __git-bug_debug "${FUNCNAME[0]}: activating no space"
84 compopt -o nospace
85 fi
86 fi
87 if [ $((directive & 4)) -ne 0 ]; then
88 if [[ $(type -t compopt) = "builtin" ]]; then
89 __git-bug_debug "${FUNCNAME[0]}: activating no file completion"
90 compopt +o default
91 fi
92 fi
93
94 while IFS='' read -r comp; do
95 COMPREPLY+=("$comp")
96 done < <(compgen -W "${out[*]}" -- "$cur")
97 fi
98}
99
100__git-bug_handle_reply()
101{
102 __git-bug_debug "${FUNCNAME[0]}"
103 local comp
104 case $cur in
105 -*)
106 if [[ $(type -t compopt) = "builtin" ]]; then
107 compopt -o nospace
108 fi
109 local allflags
110 if [ ${#must_have_one_flag[@]} -ne 0 ]; then
111 allflags=("${must_have_one_flag[@]}")
112 else
113 allflags=("${flags[*]} ${two_word_flags[*]}")
114 fi
115 while IFS='' read -r comp; do
116 COMPREPLY+=("$comp")
117 done < <(compgen -W "${allflags[*]}" -- "$cur")
118 if [[ $(type -t compopt) = "builtin" ]]; then
119 [[ "${COMPREPLY[0]}" == *= ]] || compopt +o nospace
120 fi
121
122 # complete after --flag=abc
123 if [[ $cur == *=* ]]; then
124 if [[ $(type -t compopt) = "builtin" ]]; then
125 compopt +o nospace
126 fi
127
128 local index flag
129 flag="${cur%=*}"
130 __git-bug_index_of_word "${flag}" "${flags_with_completion[@]}"
131 COMPREPLY=()
132 if [[ ${index} -ge 0 ]]; then
133 PREFIX=""
134 cur="${cur#*=}"
135 ${flags_completion[${index}]}
136 if [ -n "${ZSH_VERSION}" ]; then
137 # zsh completion needs --flag= prefix
138 eval "COMPREPLY=( \"\${COMPREPLY[@]/#/${flag}=}\" )"
139 fi
140 fi
141 fi
142 return 0;
143 ;;
144 esac
145
146 # check if we are handling a flag with special work handling
147 local index
148 __git-bug_index_of_word "${prev}" "${flags_with_completion[@]}"
149 if [[ ${index} -ge 0 ]]; then
150 ${flags_completion[${index}]}
151 return
152 fi
153
154 # we are parsing a flag and don't have a special handler, no completion
155 if [[ ${cur} != "${words[cword]}" ]]; then
156 return
157 fi
158
159 local completions
160 completions=("${commands[@]}")
161 if [[ ${#must_have_one_noun[@]} -ne 0 ]]; then
162 completions=("${must_have_one_noun[@]}")
163 elif [[ -n "${has_completion_function}" ]]; then
164 # if a go completion function is provided, defer to that function
165 completions=()
166 __git-bug_handle_go_custom_completion
167 fi
168 if [[ ${#must_have_one_flag[@]} -ne 0 ]]; then
169 completions+=("${must_have_one_flag[@]}")
170 fi
171 while IFS='' read -r comp; do
172 COMPREPLY+=("$comp")
173 done < <(compgen -W "${completions[*]}" -- "$cur")
174
175 if [[ ${#COMPREPLY[@]} -eq 0 && ${#noun_aliases[@]} -gt 0 && ${#must_have_one_noun[@]} -ne 0 ]]; then
176 while IFS='' read -r comp; do
177 COMPREPLY+=("$comp")
178 done < <(compgen -W "${noun_aliases[*]}" -- "$cur")
179 fi
180
181 if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
182 if declare -F __git-bug_custom_func >/dev/null; then
183 # try command name qualified custom func
184 __git-bug_custom_func
185 else
186 # otherwise fall back to unqualified for compatibility
187 declare -F __custom_func >/dev/null && __custom_func
188 fi
189 fi
190
191 # available in bash-completion >= 2, not always present on macOS
192 if declare -F __ltrim_colon_completions >/dev/null; then
193 __ltrim_colon_completions "$cur"
194 fi
195
196 # If there is only 1 completion and it is a flag with an = it will be completed
197 # but we don't want a space after the =
198 if [[ "${#COMPREPLY[@]}" -eq "1" ]] && [[ $(type -t compopt) = "builtin" ]] && [[ "${COMPREPLY[0]}" == --*= ]]; then
199 compopt -o nospace
200 fi
201}
202
203# The arguments should be in the form "ext1|ext2|extn"
204__git-bug_handle_filename_extension_flag()
205{
206 local ext="$1"
207 _filedir "@(${ext})"
208}
209
210__git-bug_handle_subdirs_in_dir_flag()
211{
212 local dir="$1"
213 pushd "${dir}" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 || return
214}
215
216__git-bug_handle_flag()
217{
218 __git-bug_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
219
220 # if a command required a flag, and we found it, unset must_have_one_flag()
221 local flagname=${words[c]}
222 local flagvalue
223 # if the word contained an =
224 if [[ ${words[c]} == *"="* ]]; then
225 flagvalue=${flagname#*=} # take in as flagvalue after the =
226 flagname=${flagname%=*} # strip everything after the =
227 flagname="${flagname}=" # but put the = back
228 fi
229 __git-bug_debug "${FUNCNAME[0]}: looking for ${flagname}"
230 if __git-bug_contains_word "${flagname}" "${must_have_one_flag[@]}"; then
231 must_have_one_flag=()
232 fi
233
234 # if you set a flag which only applies to this command, don't show subcommands
235 if __git-bug_contains_word "${flagname}" "${local_nonpersistent_flags[@]}"; then
236 commands=()
237 fi
238
239 # keep flag value with flagname as flaghash
240 # flaghash variable is an associative array which is only supported in bash > 3.
241 if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
242 if [ -n "${flagvalue}" ] ; then
243 flaghash[${flagname}]=${flagvalue}
244 elif [ -n "${words[ $((c+1)) ]}" ] ; then
245 flaghash[${flagname}]=${words[ $((c+1)) ]}
246 else
247 flaghash[${flagname}]="true" # pad "true" for bool flag
248 fi
249 fi
250
251 # skip the argument to a two word flag
252 if [[ ${words[c]} != *"="* ]] && __git-bug_contains_word "${words[c]}" "${two_word_flags[@]}"; then
253 __git-bug_debug "${FUNCNAME[0]}: found a flag ${words[c]}, skip the next argument"
254 c=$((c+1))
255 # if we are looking for a flags value, don't show commands
256 if [[ $c -eq $cword ]]; then
257 commands=()
258 fi
259 fi
260
261 c=$((c+1))
262
263}
264
265__git-bug_handle_noun()
266{
267 __git-bug_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
268
269 if __git-bug_contains_word "${words[c]}" "${must_have_one_noun[@]}"; then
270 must_have_one_noun=()
271 elif __git-bug_contains_word "${words[c]}" "${noun_aliases[@]}"; then
272 must_have_one_noun=()
273 fi
274
275 nouns+=("${words[c]}")
276 c=$((c+1))
277}
278
279__git-bug_handle_command()
280{
281 __git-bug_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
282
283 local next_command
284 if [[ -n ${last_command} ]]; then
285 next_command="_${last_command}_${words[c]//:/__}"
286 else
287 if [[ $c -eq 0 ]]; then
288 next_command="_git-bug_root_command"
289 else
290 next_command="_${words[c]//:/__}"
291 fi
292 fi
293 c=$((c+1))
294 __git-bug_debug "${FUNCNAME[0]}: looking for ${next_command}"
295 declare -F "$next_command" >/dev/null && $next_command
296}
297
298__git-bug_handle_word()
299{
300 if [[ $c -ge $cword ]]; then
301 __git-bug_handle_reply
302 return
303 fi
304 __git-bug_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
305 if [[ "${words[c]}" == -* ]]; then
306 __git-bug_handle_flag
307 elif __git-bug_contains_word "${words[c]}" "${commands[@]}"; then
308 __git-bug_handle_command
309 elif [[ $c -eq 0 ]]; then
310 __git-bug_handle_command
311 elif __git-bug_contains_word "${words[c]}" "${command_aliases[@]}"; then
312 # aliashash variable is an associative array which is only supported in bash > 3.
313 if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
314 words[c]=${aliashash[${words[c]}]}
315 __git-bug_handle_command
316 else
317 __git-bug_handle_noun
318 fi
319 else
320 __git-bug_handle_noun
321 fi
322 __git-bug_handle_word
323}
324
325
326_git_bug() {
327 __start_git-bug "$@"
328}
329
330_git-bug_add()
331{
332 last_command="git-bug_add"
333
334 command_aliases=()
335
336 commands=()
337
338 flags=()
339 two_word_flags=()
340 local_nonpersistent_flags=()
341 flags_with_completion=()
342 flags_completion=()
343
344 flags+=("--title=")
345 two_word_flags+=("--title")
346 two_word_flags+=("-t")
347 local_nonpersistent_flags+=("--title=")
348 flags+=("--message=")
349 two_word_flags+=("--message")
350 two_word_flags+=("-m")
351 local_nonpersistent_flags+=("--message=")
352 flags+=("--file=")
353 two_word_flags+=("--file")
354 two_word_flags+=("-F")
355 local_nonpersistent_flags+=("--file=")
356
357 must_have_one_flag=()
358 must_have_one_noun=()
359 noun_aliases=()
360}
361
362_git-bug_bridge_auth_add-token()
363{
364 last_command="git-bug_bridge_auth_add-token"
365
366 command_aliases=()
367
368 commands=()
369
370 flags=()
371 two_word_flags=()
372 local_nonpersistent_flags=()
373 flags_with_completion=()
374 flags_completion=()
375
376 flags+=("--target=")
377 two_word_flags+=("--target")
378 two_word_flags+=("-t")
379 local_nonpersistent_flags+=("--target=")
380 flags+=("--login=")
381 two_word_flags+=("--login")
382 two_word_flags+=("-l")
383 local_nonpersistent_flags+=("--login=")
384 flags+=("--user=")
385 two_word_flags+=("--user")
386 two_word_flags+=("-u")
387 local_nonpersistent_flags+=("--user=")
388
389 must_have_one_flag=()
390 must_have_one_noun=()
391 noun_aliases=()
392}
393
394_git-bug_bridge_auth_rm()
395{
396 last_command="git-bug_bridge_auth_rm"
397
398 command_aliases=()
399
400 commands=()
401
402 flags=()
403 two_word_flags=()
404 local_nonpersistent_flags=()
405 flags_with_completion=()
406 flags_completion=()
407
408
409 must_have_one_flag=()
410 must_have_one_noun=()
411 noun_aliases=()
412}
413
414_git-bug_bridge_auth_show()
415{
416 last_command="git-bug_bridge_auth_show"
417
418 command_aliases=()
419
420 commands=()
421
422 flags=()
423 two_word_flags=()
424 local_nonpersistent_flags=()
425 flags_with_completion=()
426 flags_completion=()
427
428
429 must_have_one_flag=()
430 must_have_one_noun=()
431 noun_aliases=()
432}
433
434_git-bug_bridge_auth()
435{
436 last_command="git-bug_bridge_auth"
437
438 command_aliases=()
439
440 commands=()
441 commands+=("add-token")
442 commands+=("rm")
443 commands+=("show")
444
445 flags=()
446 two_word_flags=()
447 local_nonpersistent_flags=()
448 flags_with_completion=()
449 flags_completion=()
450
451
452 must_have_one_flag=()
453 must_have_one_noun=()
454 noun_aliases=()
455}
456
457_git-bug_bridge_configure()
458{
459 last_command="git-bug_bridge_configure"
460
461 command_aliases=()
462
463 commands=()
464
465 flags=()
466 two_word_flags=()
467 local_nonpersistent_flags=()
468 flags_with_completion=()
469 flags_completion=()
470
471 flags+=("--name=")
472 two_word_flags+=("--name")
473 two_word_flags+=("-n")
474 local_nonpersistent_flags+=("--name=")
475 flags+=("--target=")
476 two_word_flags+=("--target")
477 two_word_flags+=("-t")
478 local_nonpersistent_flags+=("--target=")
479 flags+=("--url=")
480 two_word_flags+=("--url")
481 two_word_flags+=("-u")
482 local_nonpersistent_flags+=("--url=")
483 flags+=("--base-url=")
484 two_word_flags+=("--base-url")
485 two_word_flags+=("-b")
486 local_nonpersistent_flags+=("--base-url=")
487 flags+=("--login=")
488 two_word_flags+=("--login")
489 two_word_flags+=("-l")
490 local_nonpersistent_flags+=("--login=")
491 flags+=("--credential=")
492 two_word_flags+=("--credential")
493 two_word_flags+=("-c")
494 local_nonpersistent_flags+=("--credential=")
495 flags+=("--token=")
496 two_word_flags+=("--token")
497 local_nonpersistent_flags+=("--token=")
498 flags+=("--token-stdin")
499 local_nonpersistent_flags+=("--token-stdin")
500 flags+=("--owner=")
501 two_word_flags+=("--owner")
502 two_word_flags+=("-o")
503 local_nonpersistent_flags+=("--owner=")
504 flags+=("--project=")
505 two_word_flags+=("--project")
506 two_word_flags+=("-p")
507 local_nonpersistent_flags+=("--project=")
508
509 must_have_one_flag=()
510 must_have_one_noun=()
511 noun_aliases=()
512}
513
514_git-bug_bridge_pull()
515{
516 last_command="git-bug_bridge_pull"
517
518 command_aliases=()
519
520 commands=()
521
522 flags=()
523 two_word_flags=()
524 local_nonpersistent_flags=()
525 flags_with_completion=()
526 flags_completion=()
527
528 flags+=("--no-resume")
529 flags+=("-n")
530 local_nonpersistent_flags+=("--no-resume")
531 flags+=("--since=")
532 two_word_flags+=("--since")
533 two_word_flags+=("-s")
534 local_nonpersistent_flags+=("--since=")
535
536 must_have_one_flag=()
537 must_have_one_noun=()
538 noun_aliases=()
539}
540
541_git-bug_bridge_push()
542{
543 last_command="git-bug_bridge_push"
544
545 command_aliases=()
546
547 commands=()
548
549 flags=()
550 two_word_flags=()
551 local_nonpersistent_flags=()
552 flags_with_completion=()
553 flags_completion=()
554
555
556 must_have_one_flag=()
557 must_have_one_noun=()
558 noun_aliases=()
559}
560
561_git-bug_bridge_rm()
562{
563 last_command="git-bug_bridge_rm"
564
565 command_aliases=()
566
567 commands=()
568
569 flags=()
570 two_word_flags=()
571 local_nonpersistent_flags=()
572 flags_with_completion=()
573 flags_completion=()
574
575
576 must_have_one_flag=()
577 must_have_one_noun=()
578 noun_aliases=()
579}
580
581_git-bug_bridge()
582{
583 last_command="git-bug_bridge"
584
585 command_aliases=()
586
587 commands=()
588 commands+=("auth")
589 commands+=("configure")
590 commands+=("pull")
591 commands+=("push")
592 commands+=("rm")
593
594 flags=()
595 two_word_flags=()
596 local_nonpersistent_flags=()
597 flags_with_completion=()
598 flags_completion=()
599
600
601 must_have_one_flag=()
602 must_have_one_noun=()
603 noun_aliases=()
604}
605
606_git-bug_commands()
607{
608 last_command="git-bug_commands"
609
610 command_aliases=()
611
612 commands=()
613
614 flags=()
615 two_word_flags=()
616 local_nonpersistent_flags=()
617 flags_with_completion=()
618 flags_completion=()
619
620 flags+=("--pretty")
621 flags+=("-p")
622 local_nonpersistent_flags+=("--pretty")
623
624 must_have_one_flag=()
625 must_have_one_noun=()
626 noun_aliases=()
627}
628
629_git-bug_comment_add()
630{
631 last_command="git-bug_comment_add"
632
633 command_aliases=()
634
635 commands=()
636
637 flags=()
638 two_word_flags=()
639 local_nonpersistent_flags=()
640 flags_with_completion=()
641 flags_completion=()
642
643 flags+=("--file=")
644 two_word_flags+=("--file")
645 two_word_flags+=("-F")
646 local_nonpersistent_flags+=("--file=")
647 flags+=("--message=")
648 two_word_flags+=("--message")
649 two_word_flags+=("-m")
650 local_nonpersistent_flags+=("--message=")
651
652 must_have_one_flag=()
653 must_have_one_noun=()
654 noun_aliases=()
655}
656
657_git-bug_comment()
658{
659 last_command="git-bug_comment"
660
661 command_aliases=()
662
663 commands=()
664 commands+=("add")
665
666 flags=()
667 two_word_flags=()
668 local_nonpersistent_flags=()
669 flags_with_completion=()
670 flags_completion=()
671
672
673 must_have_one_flag=()
674 must_have_one_noun=()
675 noun_aliases=()
676}
677
678_git-bug_deselect()
679{
680 last_command="git-bug_deselect"
681
682 command_aliases=()
683
684 commands=()
685
686 flags=()
687 two_word_flags=()
688 local_nonpersistent_flags=()
689 flags_with_completion=()
690 flags_completion=()
691
692
693 must_have_one_flag=()
694 must_have_one_noun=()
695 noun_aliases=()
696}
697
698_git-bug_label_add()
699{
700 last_command="git-bug_label_add"
701
702 command_aliases=()
703
704 commands=()
705
706 flags=()
707 two_word_flags=()
708 local_nonpersistent_flags=()
709 flags_with_completion=()
710 flags_completion=()
711
712
713 must_have_one_flag=()
714 must_have_one_noun=()
715 noun_aliases=()
716}
717
718_git-bug_label_rm()
719{
720 last_command="git-bug_label_rm"
721
722 command_aliases=()
723
724 commands=()
725
726 flags=()
727 two_word_flags=()
728 local_nonpersistent_flags=()
729 flags_with_completion=()
730 flags_completion=()
731
732
733 must_have_one_flag=()
734 must_have_one_noun=()
735 noun_aliases=()
736}
737
738_git-bug_label()
739{
740 last_command="git-bug_label"
741
742 command_aliases=()
743
744 commands=()
745 commands+=("add")
746 commands+=("rm")
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()
761{
762 last_command="git-bug_ls"
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 flags+=("--status=")
775 two_word_flags+=("--status")
776 two_word_flags+=("-s")
777 local_nonpersistent_flags+=("--status=")
778 flags+=("--author=")
779 two_word_flags+=("--author")
780 two_word_flags+=("-a")
781 local_nonpersistent_flags+=("--author=")
782 flags+=("--participant=")
783 two_word_flags+=("--participant")
784 two_word_flags+=("-p")
785 local_nonpersistent_flags+=("--participant=")
786 flags+=("--actor=")
787 two_word_flags+=("--actor")
788 two_word_flags+=("-A")
789 local_nonpersistent_flags+=("--actor=")
790 flags+=("--label=")
791 two_word_flags+=("--label")
792 two_word_flags+=("-l")
793 local_nonpersistent_flags+=("--label=")
794 flags+=("--title=")
795 two_word_flags+=("--title")
796 two_word_flags+=("-t")
797 local_nonpersistent_flags+=("--title=")
798 flags+=("--no=")
799 two_word_flags+=("--no")
800 two_word_flags+=("-n")
801 local_nonpersistent_flags+=("--no=")
802 flags+=("--by=")
803 two_word_flags+=("--by")
804 two_word_flags+=("-b")
805 local_nonpersistent_flags+=("--by=")
806 flags+=("--direction=")
807 two_word_flags+=("--direction")
808 two_word_flags+=("-d")
809 local_nonpersistent_flags+=("--direction=")
810 flags+=("--format=")
811 two_word_flags+=("--format")
812 two_word_flags+=("-f")
813 local_nonpersistent_flags+=("--format=")
814
815 must_have_one_flag=()
816 must_have_one_noun=()
817 noun_aliases=()
818}
819
820_git-bug_ls-id()
821{
822 last_command="git-bug_ls-id"
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_ls-label()
841{
842 last_command="git-bug_ls-label"
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
855 must_have_one_flag=()
856 must_have_one_noun=()
857 noun_aliases=()
858}
859
860_git-bug_pull()
861{
862 last_command="git-bug_pull"
863
864 command_aliases=()
865
866 commands=()
867
868 flags=()
869 two_word_flags=()
870 local_nonpersistent_flags=()
871 flags_with_completion=()
872 flags_completion=()
873
874
875 must_have_one_flag=()
876 must_have_one_noun=()
877 noun_aliases=()
878}
879
880_git-bug_push()
881{
882 last_command="git-bug_push"
883
884 command_aliases=()
885
886 commands=()
887
888 flags=()
889 two_word_flags=()
890 local_nonpersistent_flags=()
891 flags_with_completion=()
892 flags_completion=()
893
894
895 must_have_one_flag=()
896 must_have_one_noun=()
897 noun_aliases=()
898}
899
900_git-bug_rm()
901{
902 last_command="git-bug_rm"
903
904 command_aliases=()
905
906 commands=()
907
908 flags=()
909 two_word_flags=()
910 local_nonpersistent_flags=()
911 flags_with_completion=()
912 flags_completion=()
913
914
915 must_have_one_flag=()
916 must_have_one_noun=()
917 noun_aliases=()
918}
919
920_git-bug_select()
921{
922 last_command="git-bug_select"
923
924 command_aliases=()
925
926 commands=()
927
928 flags=()
929 two_word_flags=()
930 local_nonpersistent_flags=()
931 flags_with_completion=()
932 flags_completion=()
933
934
935 must_have_one_flag=()
936 must_have_one_noun=()
937 noun_aliases=()
938}
939
940_git-bug_show()
941{
942 last_command="git-bug_show"
943
944 command_aliases=()
945
946 commands=()
947
948 flags=()
949 two_word_flags=()
950 local_nonpersistent_flags=()
951 flags_with_completion=()
952 flags_completion=()
953
954 flags+=("--field=")
955 two_word_flags+=("--field")
956 local_nonpersistent_flags+=("--field=")
957 flags+=("--format=")
958 two_word_flags+=("--format")
959 two_word_flags+=("-f")
960 local_nonpersistent_flags+=("--format=")
961
962 must_have_one_flag=()
963 must_have_one_noun=()
964 noun_aliases=()
965}
966
967_git-bug_status_close()
968{
969 last_command="git-bug_status_close"
970
971 command_aliases=()
972
973 commands=()
974
975 flags=()
976 two_word_flags=()
977 local_nonpersistent_flags=()
978 flags_with_completion=()
979 flags_completion=()
980
981
982 must_have_one_flag=()
983 must_have_one_noun=()
984 noun_aliases=()
985}
986
987_git-bug_status_open()
988{
989 last_command="git-bug_status_open"
990
991 command_aliases=()
992
993 commands=()
994
995 flags=()
996 two_word_flags=()
997 local_nonpersistent_flags=()
998 flags_with_completion=()
999 flags_completion=()
1000
1001
1002 must_have_one_flag=()
1003 must_have_one_noun=()
1004 noun_aliases=()
1005}
1006
1007_git-bug_status()
1008{
1009 last_command="git-bug_status"
1010
1011 command_aliases=()
1012
1013 commands=()
1014 commands+=("close")
1015 commands+=("open")
1016
1017 flags=()
1018 two_word_flags=()
1019 local_nonpersistent_flags=()
1020 flags_with_completion=()
1021 flags_completion=()
1022
1023
1024 must_have_one_flag=()
1025 must_have_one_noun=()
1026 noun_aliases=()
1027}
1028
1029_git-bug_termui()
1030{
1031 last_command="git-bug_termui"
1032
1033 command_aliases=()
1034
1035 commands=()
1036
1037 flags=()
1038 two_word_flags=()
1039 local_nonpersistent_flags=()
1040 flags_with_completion=()
1041 flags_completion=()
1042
1043
1044 must_have_one_flag=()
1045 must_have_one_noun=()
1046 noun_aliases=()
1047}
1048
1049_git-bug_title_edit()
1050{
1051 last_command="git-bug_title_edit"
1052
1053 command_aliases=()
1054
1055 commands=()
1056
1057 flags=()
1058 two_word_flags=()
1059 local_nonpersistent_flags=()
1060 flags_with_completion=()
1061 flags_completion=()
1062
1063 flags+=("--title=")
1064 two_word_flags+=("--title")
1065 two_word_flags+=("-t")
1066 local_nonpersistent_flags+=("--title=")
1067
1068 must_have_one_flag=()
1069 must_have_one_noun=()
1070 noun_aliases=()
1071}
1072
1073_git-bug_title()
1074{
1075 last_command="git-bug_title"
1076
1077 command_aliases=()
1078
1079 commands=()
1080 commands+=("edit")
1081
1082 flags=()
1083 two_word_flags=()
1084 local_nonpersistent_flags=()
1085 flags_with_completion=()
1086 flags_completion=()
1087
1088
1089 must_have_one_flag=()
1090 must_have_one_noun=()
1091 noun_aliases=()
1092}
1093
1094_git-bug_user_adopt()
1095{
1096 last_command="git-bug_user_adopt"
1097
1098 command_aliases=()
1099
1100 commands=()
1101
1102 flags=()
1103 two_word_flags=()
1104 local_nonpersistent_flags=()
1105 flags_with_completion=()
1106 flags_completion=()
1107
1108
1109 must_have_one_flag=()
1110 must_have_one_noun=()
1111 noun_aliases=()
1112}
1113
1114_git-bug_user_create()
1115{
1116 last_command="git-bug_user_create"
1117
1118 command_aliases=()
1119
1120 commands=()
1121
1122 flags=()
1123 two_word_flags=()
1124 local_nonpersistent_flags=()
1125 flags_with_completion=()
1126 flags_completion=()
1127
1128
1129 must_have_one_flag=()
1130 must_have_one_noun=()
1131 noun_aliases=()
1132}
1133
1134_git-bug_user_ls()
1135{
1136 last_command="git-bug_user_ls"
1137
1138 command_aliases=()
1139
1140 commands=()
1141
1142 flags=()
1143 two_word_flags=()
1144 local_nonpersistent_flags=()
1145 flags_with_completion=()
1146 flags_completion=()
1147
1148 flags+=("--format=")
1149 two_word_flags+=("--format")
1150 two_word_flags+=("-f")
1151 local_nonpersistent_flags+=("--format=")
1152
1153 must_have_one_flag=()
1154 must_have_one_noun=()
1155 noun_aliases=()
1156}
1157
1158_git-bug_user()
1159{
1160 last_command="git-bug_user"
1161
1162 command_aliases=()
1163
1164 commands=()
1165 commands+=("adopt")
1166 commands+=("create")
1167 commands+=("ls")
1168
1169 flags=()
1170 two_word_flags=()
1171 local_nonpersistent_flags=()
1172 flags_with_completion=()
1173 flags_completion=()
1174
1175 flags+=("--field=")
1176 two_word_flags+=("--field")
1177 two_word_flags+=("-f")
1178 local_nonpersistent_flags+=("--field=")
1179
1180 must_have_one_flag=()
1181 must_have_one_noun=()
1182 noun_aliases=()
1183}
1184
1185_git-bug_version()
1186{
1187 last_command="git-bug_version"
1188
1189 command_aliases=()
1190
1191 commands=()
1192
1193 flags=()
1194 two_word_flags=()
1195 local_nonpersistent_flags=()
1196 flags_with_completion=()
1197 flags_completion=()
1198
1199 flags+=("--number")
1200 flags+=("-n")
1201 local_nonpersistent_flags+=("--number")
1202 flags+=("--commit")
1203 flags+=("-c")
1204 local_nonpersistent_flags+=("--commit")
1205 flags+=("--all")
1206 flags+=("-a")
1207 local_nonpersistent_flags+=("--all")
1208
1209 must_have_one_flag=()
1210 must_have_one_noun=()
1211 noun_aliases=()
1212}
1213
1214_git-bug_webui()
1215{
1216 last_command="git-bug_webui"
1217
1218 command_aliases=()
1219
1220 commands=()
1221
1222 flags=()
1223 two_word_flags=()
1224 local_nonpersistent_flags=()
1225 flags_with_completion=()
1226 flags_completion=()
1227
1228 flags+=("--open")
1229 local_nonpersistent_flags+=("--open")
1230 flags+=("--no-open")
1231 local_nonpersistent_flags+=("--no-open")
1232 flags+=("--port=")
1233 two_word_flags+=("--port")
1234 two_word_flags+=("-p")
1235 local_nonpersistent_flags+=("--port=")
1236 flags+=("--read-only")
1237 local_nonpersistent_flags+=("--read-only")
1238
1239 must_have_one_flag=()
1240 must_have_one_noun=()
1241 noun_aliases=()
1242}
1243
1244_git-bug_root_command()
1245{
1246 last_command="git-bug"
1247
1248 command_aliases=()
1249
1250 commands=()
1251 commands+=("add")
1252 commands+=("bridge")
1253 commands+=("commands")
1254 commands+=("comment")
1255 commands+=("deselect")
1256 commands+=("label")
1257 commands+=("ls")
1258 commands+=("ls-id")
1259 commands+=("ls-label")
1260 commands+=("pull")
1261 commands+=("push")
1262 commands+=("rm")
1263 commands+=("select")
1264 commands+=("show")
1265 commands+=("status")
1266 commands+=("termui")
1267 if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
1268 command_aliases+=("tui")
1269 aliashash["tui"]="termui"
1270 fi
1271 commands+=("title")
1272 commands+=("user")
1273 commands+=("version")
1274 commands+=("webui")
1275
1276 flags=()
1277 two_word_flags=()
1278 local_nonpersistent_flags=()
1279 flags_with_completion=()
1280 flags_completion=()
1281
1282
1283 must_have_one_flag=()
1284 must_have_one_noun=()
1285 noun_aliases=()
1286}
1287
1288__start_git-bug()
1289{
1290 local cur prev words cword
1291 declare -A flaghash 2>/dev/null || :
1292 declare -A aliashash 2>/dev/null || :
1293 if declare -F _init_completion >/dev/null 2>&1; then
1294 _init_completion -s || return
1295 else
1296 __git-bug_init_completion -n "=" || return
1297 fi
1298
1299 local c=0
1300 local flags=()
1301 local two_word_flags=()
1302 local local_nonpersistent_flags=()
1303 local flags_with_completion=()
1304 local flags_completion=()
1305 local commands=("git-bug")
1306 local must_have_one_flag=()
1307 local must_have_one_noun=()
1308 local has_completion_function
1309 local last_command
1310 local nouns=()
1311
1312 __git-bug_handle_word
1313}
1314
1315if [[ $(type -t compopt) = "builtin" ]]; then
1316 complete -o default -F __start_git-bug git-bug
1317else
1318 complete -o default -o nospace -F __start_git-bug git-bug
1319fi
1320
1321# ex: ts=4 sw=4 et filetype=sh