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 shellCompDirectiveError=1
44 local shellCompDirectiveNoSpace=2
45 local shellCompDirectiveNoFileComp=4
46 local shellCompDirectiveFilterFileExt=8
47 local shellCompDirectiveFilterDirs=16
48
49 local out requestComp lastParam lastChar comp directive args
50
51 # Prepare the command to request completions for the program.
52 # Calling ${words[0]} instead of directly git-bug allows to handle aliases
53 args=("${words[@]:1}")
54 requestComp="${words[0]} __completeNoDesc ${args[*]}"
55
56 lastParam=${words[$((${#words[@]}-1))]}
57 lastChar=${lastParam:$((${#lastParam}-1)):1}
58 __git-bug_debug "${FUNCNAME[0]}: lastParam ${lastParam}, lastChar ${lastChar}"
59
60 if [ -z "${cur}" ] && [ "${lastChar}" != "=" ]; then
61 # If the last parameter is complete (there is a space following it)
62 # We add an extra empty parameter so we can indicate this to the go method.
63 __git-bug_debug "${FUNCNAME[0]}: Adding extra empty parameter"
64 requestComp="${requestComp} \"\""
65 fi
66
67 __git-bug_debug "${FUNCNAME[0]}: calling ${requestComp}"
68 # Use eval to handle any environment variables and such
69 out=$(eval "${requestComp}" 2>/dev/null)
70
71 # Extract the directive integer at the very end of the output following a colon (:)
72 directive=${out##*:}
73 # Remove the directive
74 out=${out%:*}
75 if [ "${directive}" = "${out}" ]; then
76 # There is not directive specified
77 directive=0
78 fi
79 __git-bug_debug "${FUNCNAME[0]}: the completion directive is: ${directive}"
80 __git-bug_debug "${FUNCNAME[0]}: the completions are: ${out[*]}"
81
82 if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
83 # Error code. No completion.
84 __git-bug_debug "${FUNCNAME[0]}: received error from custom completion go code"
85 return
86 else
87 if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
88 if [[ $(type -t compopt) = "builtin" ]]; then
89 __git-bug_debug "${FUNCNAME[0]}: activating no space"
90 compopt -o nospace
91 fi
92 fi
93 if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
94 if [[ $(type -t compopt) = "builtin" ]]; then
95 __git-bug_debug "${FUNCNAME[0]}: activating no file completion"
96 compopt +o default
97 fi
98 fi
99 fi
100
101 if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
102 # File extension filtering
103 local fullFilter filter filteringCmd
104 # Do not use quotes around the $out variable or else newline
105 # characters will be kept.
106 for filter in ${out[*]}; do
107 fullFilter+="$filter|"
108 done
109
110 filteringCmd="_filedir $fullFilter"
111 __git-bug_debug "File filtering command: $filteringCmd"
112 $filteringCmd
113 elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
114 # File completion for directories only
115 local subDir
116 # Use printf to strip any trailing newline
117 subdir=$(printf "%s" "${out[0]}")
118 if [ -n "$subdir" ]; then
119 __git-bug_debug "Listing directories in $subdir"
120 __git-bug_handle_subdirs_in_dir_flag "$subdir"
121 else
122 __git-bug_debug "Listing directories in ."
123 _filedir -d
124 fi
125 else
126 while IFS='' read -r comp; do
127 COMPREPLY+=("$comp")
128 done < <(compgen -W "${out[*]}" -- "$cur")
129 fi
130}
131
132__git-bug_handle_reply()
133{
134 __git-bug_debug "${FUNCNAME[0]}"
135 local comp
136 case $cur in
137 -*)
138 if [[ $(type -t compopt) = "builtin" ]]; then
139 compopt -o nospace
140 fi
141 local allflags
142 if [ ${#must_have_one_flag[@]} -ne 0 ]; then
143 allflags=("${must_have_one_flag[@]}")
144 else
145 allflags=("${flags[*]} ${two_word_flags[*]}")
146 fi
147 while IFS='' read -r comp; do
148 COMPREPLY+=("$comp")
149 done < <(compgen -W "${allflags[*]}" -- "$cur")
150 if [[ $(type -t compopt) = "builtin" ]]; then
151 [[ "${COMPREPLY[0]}" == *= ]] || compopt +o nospace
152 fi
153
154 # complete after --flag=abc
155 if [[ $cur == *=* ]]; then
156 if [[ $(type -t compopt) = "builtin" ]]; then
157 compopt +o nospace
158 fi
159
160 local index flag
161 flag="${cur%=*}"
162 __git-bug_index_of_word "${flag}" "${flags_with_completion[@]}"
163 COMPREPLY=()
164 if [[ ${index} -ge 0 ]]; then
165 PREFIX=""
166 cur="${cur#*=}"
167 ${flags_completion[${index}]}
168 if [ -n "${ZSH_VERSION}" ]; then
169 # zsh completion needs --flag= prefix
170 eval "COMPREPLY=( \"\${COMPREPLY[@]/#/${flag}=}\" )"
171 fi
172 fi
173 fi
174 return 0;
175 ;;
176 esac
177
178 # check if we are handling a flag with special work handling
179 local index
180 __git-bug_index_of_word "${prev}" "${flags_with_completion[@]}"
181 if [[ ${index} -ge 0 ]]; then
182 ${flags_completion[${index}]}
183 return
184 fi
185
186 # we are parsing a flag and don't have a special handler, no completion
187 if [[ ${cur} != "${words[cword]}" ]]; then
188 return
189 fi
190
191 local completions
192 completions=("${commands[@]}")
193 if [[ ${#must_have_one_noun[@]} -ne 0 ]]; then
194 completions+=("${must_have_one_noun[@]}")
195 elif [[ -n "${has_completion_function}" ]]; then
196 # if a go completion function is provided, defer to that function
197 __git-bug_handle_go_custom_completion
198 fi
199 if [[ ${#must_have_one_flag[@]} -ne 0 ]]; then
200 completions+=("${must_have_one_flag[@]}")
201 fi
202 while IFS='' read -r comp; do
203 COMPREPLY+=("$comp")
204 done < <(compgen -W "${completions[*]}" -- "$cur")
205
206 if [[ ${#COMPREPLY[@]} -eq 0 && ${#noun_aliases[@]} -gt 0 && ${#must_have_one_noun[@]} -ne 0 ]]; then
207 while IFS='' read -r comp; do
208 COMPREPLY+=("$comp")
209 done < <(compgen -W "${noun_aliases[*]}" -- "$cur")
210 fi
211
212 if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
213 if declare -F __git-bug_custom_func >/dev/null; then
214 # try command name qualified custom func
215 __git-bug_custom_func
216 else
217 # otherwise fall back to unqualified for compatibility
218 declare -F __custom_func >/dev/null && __custom_func
219 fi
220 fi
221
222 # available in bash-completion >= 2, not always present on macOS
223 if declare -F __ltrim_colon_completions >/dev/null; then
224 __ltrim_colon_completions "$cur"
225 fi
226
227 # If there is only 1 completion and it is a flag with an = it will be completed
228 # but we don't want a space after the =
229 if [[ "${#COMPREPLY[@]}" -eq "1" ]] && [[ $(type -t compopt) = "builtin" ]] && [[ "${COMPREPLY[0]}" == --*= ]]; then
230 compopt -o nospace
231 fi
232}
233
234# The arguments should be in the form "ext1|ext2|extn"
235__git-bug_handle_filename_extension_flag()
236{
237 local ext="$1"
238 _filedir "@(${ext})"
239}
240
241__git-bug_handle_subdirs_in_dir_flag()
242{
243 local dir="$1"
244 pushd "${dir}" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 || return
245}
246
247__git-bug_handle_flag()
248{
249 __git-bug_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
250
251 # if a command required a flag, and we found it, unset must_have_one_flag()
252 local flagname=${words[c]}
253 local flagvalue
254 # if the word contained an =
255 if [[ ${words[c]} == *"="* ]]; then
256 flagvalue=${flagname#*=} # take in as flagvalue after the =
257 flagname=${flagname%=*} # strip everything after the =
258 flagname="${flagname}=" # but put the = back
259 fi
260 __git-bug_debug "${FUNCNAME[0]}: looking for ${flagname}"
261 if __git-bug_contains_word "${flagname}" "${must_have_one_flag[@]}"; then
262 must_have_one_flag=()
263 fi
264
265 # if you set a flag which only applies to this command, don't show subcommands
266 if __git-bug_contains_word "${flagname}" "${local_nonpersistent_flags[@]}"; then
267 commands=()
268 fi
269
270 # keep flag value with flagname as flaghash
271 # flaghash variable is an associative array which is only supported in bash > 3.
272 if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
273 if [ -n "${flagvalue}" ] ; then
274 flaghash[${flagname}]=${flagvalue}
275 elif [ -n "${words[ $((c+1)) ]}" ] ; then
276 flaghash[${flagname}]=${words[ $((c+1)) ]}
277 else
278 flaghash[${flagname}]="true" # pad "true" for bool flag
279 fi
280 fi
281
282 # skip the argument to a two word flag
283 if [[ ${words[c]} != *"="* ]] && __git-bug_contains_word "${words[c]}" "${two_word_flags[@]}"; then
284 __git-bug_debug "${FUNCNAME[0]}: found a flag ${words[c]}, skip the next argument"
285 c=$((c+1))
286 # if we are looking for a flags value, don't show commands
287 if [[ $c -eq $cword ]]; then
288 commands=()
289 fi
290 fi
291
292 c=$((c+1))
293
294}
295
296__git-bug_handle_noun()
297{
298 __git-bug_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
299
300 if __git-bug_contains_word "${words[c]}" "${must_have_one_noun[@]}"; then
301 must_have_one_noun=()
302 elif __git-bug_contains_word "${words[c]}" "${noun_aliases[@]}"; then
303 must_have_one_noun=()
304 fi
305
306 nouns+=("${words[c]}")
307 c=$((c+1))
308}
309
310__git-bug_handle_command()
311{
312 __git-bug_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
313
314 local next_command
315 if [[ -n ${last_command} ]]; then
316 next_command="_${last_command}_${words[c]//:/__}"
317 else
318 if [[ $c -eq 0 ]]; then
319 next_command="_git-bug_root_command"
320 else
321 next_command="_${words[c]//:/__}"
322 fi
323 fi
324 c=$((c+1))
325 __git-bug_debug "${FUNCNAME[0]}: looking for ${next_command}"
326 declare -F "$next_command" >/dev/null && $next_command
327}
328
329__git-bug_handle_word()
330{
331 if [[ $c -ge $cword ]]; then
332 __git-bug_handle_reply
333 return
334 fi
335 __git-bug_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
336 if [[ "${words[c]}" == -* ]]; then
337 __git-bug_handle_flag
338 elif __git-bug_contains_word "${words[c]}" "${commands[@]}"; then
339 __git-bug_handle_command
340 elif [[ $c -eq 0 ]]; then
341 __git-bug_handle_command
342 elif __git-bug_contains_word "${words[c]}" "${command_aliases[@]}"; then
343 # aliashash variable is an associative array which is only supported in bash > 3.
344 if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
345 words[c]=${aliashash[${words[c]}]}
346 __git-bug_handle_command
347 else
348 __git-bug_handle_noun
349 fi
350 else
351 __git-bug_handle_noun
352 fi
353 __git-bug_handle_word
354}
355
356
357_git_bug() {
358 __start_git-bug "$@"
359}
360
361_git-bug_add()
362{
363 last_command="git-bug_add"
364
365 command_aliases=()
366
367 commands=()
368
369 flags=()
370 two_word_flags=()
371 local_nonpersistent_flags=()
372 flags_with_completion=()
373 flags_completion=()
374
375 flags+=("--title=")
376 two_word_flags+=("--title")
377 two_word_flags+=("-t")
378 local_nonpersistent_flags+=("--title")
379 local_nonpersistent_flags+=("--title=")
380 local_nonpersistent_flags+=("-t")
381 flags+=("--message=")
382 two_word_flags+=("--message")
383 two_word_flags+=("-m")
384 local_nonpersistent_flags+=("--message")
385 local_nonpersistent_flags+=("--message=")
386 local_nonpersistent_flags+=("-m")
387 flags+=("--file=")
388 two_word_flags+=("--file")
389 two_word_flags+=("-F")
390 local_nonpersistent_flags+=("--file")
391 local_nonpersistent_flags+=("--file=")
392 local_nonpersistent_flags+=("-F")
393
394 must_have_one_flag=()
395 must_have_one_noun=()
396 noun_aliases=()
397}
398
399_git-bug_bridge_auth_add-token()
400{
401 last_command="git-bug_bridge_auth_add-token"
402
403 command_aliases=()
404
405 commands=()
406
407 flags=()
408 two_word_flags=()
409 local_nonpersistent_flags=()
410 flags_with_completion=()
411 flags_completion=()
412
413 flags+=("--target=")
414 two_word_flags+=("--target")
415 two_word_flags+=("-t")
416 local_nonpersistent_flags+=("--target")
417 local_nonpersistent_flags+=("--target=")
418 local_nonpersistent_flags+=("-t")
419 flags+=("--login=")
420 two_word_flags+=("--login")
421 two_word_flags+=("-l")
422 local_nonpersistent_flags+=("--login")
423 local_nonpersistent_flags+=("--login=")
424 local_nonpersistent_flags+=("-l")
425 flags+=("--user=")
426 two_word_flags+=("--user")
427 two_word_flags+=("-u")
428 local_nonpersistent_flags+=("--user")
429 local_nonpersistent_flags+=("--user=")
430 local_nonpersistent_flags+=("-u")
431
432 must_have_one_flag=()
433 must_have_one_noun=()
434 noun_aliases=()
435}
436
437_git-bug_bridge_auth_rm()
438{
439 last_command="git-bug_bridge_auth_rm"
440
441 command_aliases=()
442
443 commands=()
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_auth_show()
458{
459 last_command="git-bug_bridge_auth_show"
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
472 must_have_one_flag=()
473 must_have_one_noun=()
474 noun_aliases=()
475}
476
477_git-bug_bridge_auth()
478{
479 last_command="git-bug_bridge_auth"
480
481 command_aliases=()
482
483 commands=()
484 commands+=("add-token")
485 commands+=("rm")
486 commands+=("show")
487
488 flags=()
489 two_word_flags=()
490 local_nonpersistent_flags=()
491 flags_with_completion=()
492 flags_completion=()
493
494
495 must_have_one_flag=()
496 must_have_one_noun=()
497 noun_aliases=()
498}
499
500_git-bug_bridge_configure()
501{
502 last_command="git-bug_bridge_configure"
503
504 command_aliases=()
505
506 commands=()
507
508 flags=()
509 two_word_flags=()
510 local_nonpersistent_flags=()
511 flags_with_completion=()
512 flags_completion=()
513
514 flags+=("--name=")
515 two_word_flags+=("--name")
516 two_word_flags+=("-n")
517 local_nonpersistent_flags+=("--name")
518 local_nonpersistent_flags+=("--name=")
519 local_nonpersistent_flags+=("-n")
520 flags+=("--target=")
521 two_word_flags+=("--target")
522 two_word_flags+=("-t")
523 local_nonpersistent_flags+=("--target")
524 local_nonpersistent_flags+=("--target=")
525 local_nonpersistent_flags+=("-t")
526 flags+=("--url=")
527 two_word_flags+=("--url")
528 two_word_flags+=("-u")
529 local_nonpersistent_flags+=("--url")
530 local_nonpersistent_flags+=("--url=")
531 local_nonpersistent_flags+=("-u")
532 flags+=("--base-url=")
533 two_word_flags+=("--base-url")
534 two_word_flags+=("-b")
535 local_nonpersistent_flags+=("--base-url")
536 local_nonpersistent_flags+=("--base-url=")
537 local_nonpersistent_flags+=("-b")
538 flags+=("--login=")
539 two_word_flags+=("--login")
540 two_word_flags+=("-l")
541 local_nonpersistent_flags+=("--login")
542 local_nonpersistent_flags+=("--login=")
543 local_nonpersistent_flags+=("-l")
544 flags+=("--credential=")
545 two_word_flags+=("--credential")
546 two_word_flags+=("-c")
547 local_nonpersistent_flags+=("--credential")
548 local_nonpersistent_flags+=("--credential=")
549 local_nonpersistent_flags+=("-c")
550 flags+=("--token=")
551 two_word_flags+=("--token")
552 local_nonpersistent_flags+=("--token")
553 local_nonpersistent_flags+=("--token=")
554 flags+=("--token-stdin")
555 local_nonpersistent_flags+=("--token-stdin")
556 flags+=("--owner=")
557 two_word_flags+=("--owner")
558 two_word_flags+=("-o")
559 local_nonpersistent_flags+=("--owner")
560 local_nonpersistent_flags+=("--owner=")
561 local_nonpersistent_flags+=("-o")
562 flags+=("--project=")
563 two_word_flags+=("--project")
564 two_word_flags+=("-p")
565 local_nonpersistent_flags+=("--project")
566 local_nonpersistent_flags+=("--project=")
567 local_nonpersistent_flags+=("-p")
568
569 must_have_one_flag=()
570 must_have_one_noun=()
571 noun_aliases=()
572}
573
574_git-bug_bridge_pull()
575{
576 last_command="git-bug_bridge_pull"
577
578 command_aliases=()
579
580 commands=()
581
582 flags=()
583 two_word_flags=()
584 local_nonpersistent_flags=()
585 flags_with_completion=()
586 flags_completion=()
587
588 flags+=("--no-resume")
589 flags+=("-n")
590 local_nonpersistent_flags+=("--no-resume")
591 local_nonpersistent_flags+=("-n")
592 flags+=("--since=")
593 two_word_flags+=("--since")
594 two_word_flags+=("-s")
595 local_nonpersistent_flags+=("--since")
596 local_nonpersistent_flags+=("--since=")
597 local_nonpersistent_flags+=("-s")
598
599 must_have_one_flag=()
600 must_have_one_noun=()
601 noun_aliases=()
602}
603
604_git-bug_bridge_push()
605{
606 last_command="git-bug_bridge_push"
607
608 command_aliases=()
609
610 commands=()
611
612 flags=()
613 two_word_flags=()
614 local_nonpersistent_flags=()
615 flags_with_completion=()
616 flags_completion=()
617
618
619 must_have_one_flag=()
620 must_have_one_noun=()
621 noun_aliases=()
622}
623
624_git-bug_bridge_rm()
625{
626 last_command="git-bug_bridge_rm"
627
628 command_aliases=()
629
630 commands=()
631
632 flags=()
633 two_word_flags=()
634 local_nonpersistent_flags=()
635 flags_with_completion=()
636 flags_completion=()
637
638
639 must_have_one_flag=()
640 must_have_one_noun=()
641 noun_aliases=()
642}
643
644_git-bug_bridge()
645{
646 last_command="git-bug_bridge"
647
648 command_aliases=()
649
650 commands=()
651 commands+=("auth")
652 commands+=("configure")
653 commands+=("pull")
654 commands+=("push")
655 commands+=("rm")
656
657 flags=()
658 two_word_flags=()
659 local_nonpersistent_flags=()
660 flags_with_completion=()
661 flags_completion=()
662
663
664 must_have_one_flag=()
665 must_have_one_noun=()
666 noun_aliases=()
667}
668
669_git-bug_commands()
670{
671 last_command="git-bug_commands"
672
673 command_aliases=()
674
675 commands=()
676
677 flags=()
678 two_word_flags=()
679 local_nonpersistent_flags=()
680 flags_with_completion=()
681 flags_completion=()
682
683 flags+=("--pretty")
684 flags+=("-p")
685 local_nonpersistent_flags+=("--pretty")
686 local_nonpersistent_flags+=("-p")
687
688 must_have_one_flag=()
689 must_have_one_noun=()
690 noun_aliases=()
691}
692
693_git-bug_comment_add()
694{
695 last_command="git-bug_comment_add"
696
697 command_aliases=()
698
699 commands=()
700
701 flags=()
702 two_word_flags=()
703 local_nonpersistent_flags=()
704 flags_with_completion=()
705 flags_completion=()
706
707 flags+=("--file=")
708 two_word_flags+=("--file")
709 two_word_flags+=("-F")
710 local_nonpersistent_flags+=("--file")
711 local_nonpersistent_flags+=("--file=")
712 local_nonpersistent_flags+=("-F")
713 flags+=("--message=")
714 two_word_flags+=("--message")
715 two_word_flags+=("-m")
716 local_nonpersistent_flags+=("--message")
717 local_nonpersistent_flags+=("--message=")
718 local_nonpersistent_flags+=("-m")
719
720 must_have_one_flag=()
721 must_have_one_noun=()
722 noun_aliases=()
723}
724
725_git-bug_comment_edit()
726{
727 last_command="git-bug_comment_edit"
728
729 command_aliases=()
730
731 commands=()
732
733 flags=()
734 two_word_flags=()
735 local_nonpersistent_flags=()
736 flags_with_completion=()
737 flags_completion=()
738
739 flags+=("--file=")
740 two_word_flags+=("--file")
741 two_word_flags+=("-F")
742 local_nonpersistent_flags+=("--file")
743 local_nonpersistent_flags+=("--file=")
744 local_nonpersistent_flags+=("-F")
745 flags+=("--message=")
746 two_word_flags+=("--message")
747 two_word_flags+=("-m")
748 local_nonpersistent_flags+=("--message")
749 local_nonpersistent_flags+=("--message=")
750 local_nonpersistent_flags+=("-m")
751
752 must_have_one_flag=()
753 must_have_one_noun=()
754 noun_aliases=()
755}
756
757_git-bug_comment()
758{
759 last_command="git-bug_comment"
760
761 command_aliases=()
762
763 commands=()
764 commands+=("add")
765 commands+=("edit")
766
767 flags=()
768 two_word_flags=()
769 local_nonpersistent_flags=()
770 flags_with_completion=()
771 flags_completion=()
772
773
774 must_have_one_flag=()
775 must_have_one_noun=()
776 noun_aliases=()
777}
778
779_git-bug_deselect()
780{
781 last_command="git-bug_deselect"
782
783 command_aliases=()
784
785 commands=()
786
787 flags=()
788 two_word_flags=()
789 local_nonpersistent_flags=()
790 flags_with_completion=()
791 flags_completion=()
792
793
794 must_have_one_flag=()
795 must_have_one_noun=()
796 noun_aliases=()
797}
798
799_git-bug_label_add()
800{
801 last_command="git-bug_label_add"
802
803 command_aliases=()
804
805 commands=()
806
807 flags=()
808 two_word_flags=()
809 local_nonpersistent_flags=()
810 flags_with_completion=()
811 flags_completion=()
812
813
814 must_have_one_flag=()
815 must_have_one_noun=()
816 noun_aliases=()
817}
818
819_git-bug_label_rm()
820{
821 last_command="git-bug_label_rm"
822
823 command_aliases=()
824
825 commands=()
826
827 flags=()
828 two_word_flags=()
829 local_nonpersistent_flags=()
830 flags_with_completion=()
831 flags_completion=()
832
833
834 must_have_one_flag=()
835 must_have_one_noun=()
836 noun_aliases=()
837}
838
839_git-bug_label()
840{
841 last_command="git-bug_label"
842
843 command_aliases=()
844
845 commands=()
846 commands+=("add")
847 commands+=("rm")
848
849 flags=()
850 two_word_flags=()
851 local_nonpersistent_flags=()
852 flags_with_completion=()
853 flags_completion=()
854
855
856 must_have_one_flag=()
857 must_have_one_noun=()
858 noun_aliases=()
859}
860
861_git-bug_ls()
862{
863 last_command="git-bug_ls"
864
865 command_aliases=()
866
867 commands=()
868
869 flags=()
870 two_word_flags=()
871 local_nonpersistent_flags=()
872 flags_with_completion=()
873 flags_completion=()
874
875 flags+=("--status=")
876 two_word_flags+=("--status")
877 two_word_flags+=("-s")
878 local_nonpersistent_flags+=("--status")
879 local_nonpersistent_flags+=("--status=")
880 local_nonpersistent_flags+=("-s")
881 flags+=("--author=")
882 two_word_flags+=("--author")
883 two_word_flags+=("-a")
884 local_nonpersistent_flags+=("--author")
885 local_nonpersistent_flags+=("--author=")
886 local_nonpersistent_flags+=("-a")
887 flags+=("--metadata=")
888 two_word_flags+=("--metadata")
889 two_word_flags+=("-m")
890 local_nonpersistent_flags+=("--metadata")
891 local_nonpersistent_flags+=("--metadata=")
892 local_nonpersistent_flags+=("-m")
893 flags+=("--participant=")
894 two_word_flags+=("--participant")
895 two_word_flags+=("-p")
896 local_nonpersistent_flags+=("--participant")
897 local_nonpersistent_flags+=("--participant=")
898 local_nonpersistent_flags+=("-p")
899 flags+=("--actor=")
900 two_word_flags+=("--actor")
901 two_word_flags+=("-A")
902 local_nonpersistent_flags+=("--actor")
903 local_nonpersistent_flags+=("--actor=")
904 local_nonpersistent_flags+=("-A")
905 flags+=("--label=")
906 two_word_flags+=("--label")
907 two_word_flags+=("-l")
908 local_nonpersistent_flags+=("--label")
909 local_nonpersistent_flags+=("--label=")
910 local_nonpersistent_flags+=("-l")
911 flags+=("--title=")
912 two_word_flags+=("--title")
913 two_word_flags+=("-t")
914 local_nonpersistent_flags+=("--title")
915 local_nonpersistent_flags+=("--title=")
916 local_nonpersistent_flags+=("-t")
917 flags+=("--no=")
918 two_word_flags+=("--no")
919 two_word_flags+=("-n")
920 local_nonpersistent_flags+=("--no")
921 local_nonpersistent_flags+=("--no=")
922 local_nonpersistent_flags+=("-n")
923 flags+=("--by=")
924 two_word_flags+=("--by")
925 two_word_flags+=("-b")
926 local_nonpersistent_flags+=("--by")
927 local_nonpersistent_flags+=("--by=")
928 local_nonpersistent_flags+=("-b")
929 flags+=("--direction=")
930 two_word_flags+=("--direction")
931 two_word_flags+=("-d")
932 local_nonpersistent_flags+=("--direction")
933 local_nonpersistent_flags+=("--direction=")
934 local_nonpersistent_flags+=("-d")
935 flags+=("--format=")
936 two_word_flags+=("--format")
937 two_word_flags+=("-f")
938 local_nonpersistent_flags+=("--format")
939 local_nonpersistent_flags+=("--format=")
940 local_nonpersistent_flags+=("-f")
941
942 must_have_one_flag=()
943 must_have_one_noun=()
944 noun_aliases=()
945}
946
947_git-bug_ls-id()
948{
949 last_command="git-bug_ls-id"
950
951 command_aliases=()
952
953 commands=()
954
955 flags=()
956 two_word_flags=()
957 local_nonpersistent_flags=()
958 flags_with_completion=()
959 flags_completion=()
960
961
962 must_have_one_flag=()
963 must_have_one_noun=()
964 noun_aliases=()
965}
966
967_git-bug_ls-label()
968{
969 last_command="git-bug_ls-label"
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_pull()
988{
989 last_command="git-bug_pull"
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_push()
1008{
1009 last_command="git-bug_push"
1010
1011 command_aliases=()
1012
1013 commands=()
1014
1015 flags=()
1016 two_word_flags=()
1017 local_nonpersistent_flags=()
1018 flags_with_completion=()
1019 flags_completion=()
1020
1021
1022 must_have_one_flag=()
1023 must_have_one_noun=()
1024 noun_aliases=()
1025}
1026
1027_git-bug_rm()
1028{
1029 last_command="git-bug_rm"
1030
1031 command_aliases=()
1032
1033 commands=()
1034
1035 flags=()
1036 two_word_flags=()
1037 local_nonpersistent_flags=()
1038 flags_with_completion=()
1039 flags_completion=()
1040
1041
1042 must_have_one_flag=()
1043 must_have_one_noun=()
1044 noun_aliases=()
1045}
1046
1047_git-bug_select()
1048{
1049 last_command="git-bug_select"
1050
1051 command_aliases=()
1052
1053 commands=()
1054
1055 flags=()
1056 two_word_flags=()
1057 local_nonpersistent_flags=()
1058 flags_with_completion=()
1059 flags_completion=()
1060
1061
1062 must_have_one_flag=()
1063 must_have_one_noun=()
1064 noun_aliases=()
1065}
1066
1067_git-bug_show()
1068{
1069 last_command="git-bug_show"
1070
1071 command_aliases=()
1072
1073 commands=()
1074
1075 flags=()
1076 two_word_flags=()
1077 local_nonpersistent_flags=()
1078 flags_with_completion=()
1079 flags_completion=()
1080
1081 flags+=("--field=")
1082 two_word_flags+=("--field")
1083 local_nonpersistent_flags+=("--field")
1084 local_nonpersistent_flags+=("--field=")
1085 flags+=("--format=")
1086 two_word_flags+=("--format")
1087 two_word_flags+=("-f")
1088 local_nonpersistent_flags+=("--format")
1089 local_nonpersistent_flags+=("--format=")
1090 local_nonpersistent_flags+=("-f")
1091
1092 must_have_one_flag=()
1093 must_have_one_noun=()
1094 noun_aliases=()
1095}
1096
1097_git-bug_status_close()
1098{
1099 last_command="git-bug_status_close"
1100
1101 command_aliases=()
1102
1103 commands=()
1104
1105 flags=()
1106 two_word_flags=()
1107 local_nonpersistent_flags=()
1108 flags_with_completion=()
1109 flags_completion=()
1110
1111
1112 must_have_one_flag=()
1113 must_have_one_noun=()
1114 noun_aliases=()
1115}
1116
1117_git-bug_status_open()
1118{
1119 last_command="git-bug_status_open"
1120
1121 command_aliases=()
1122
1123 commands=()
1124
1125 flags=()
1126 two_word_flags=()
1127 local_nonpersistent_flags=()
1128 flags_with_completion=()
1129 flags_completion=()
1130
1131
1132 must_have_one_flag=()
1133 must_have_one_noun=()
1134 noun_aliases=()
1135}
1136
1137_git-bug_status()
1138{
1139 last_command="git-bug_status"
1140
1141 command_aliases=()
1142
1143 commands=()
1144 commands+=("close")
1145 commands+=("open")
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_git-bug_termui()
1160{
1161 last_command="git-bug_termui"
1162
1163 command_aliases=()
1164
1165 commands=()
1166
1167 flags=()
1168 two_word_flags=()
1169 local_nonpersistent_flags=()
1170 flags_with_completion=()
1171 flags_completion=()
1172
1173
1174 must_have_one_flag=()
1175 must_have_one_noun=()
1176 noun_aliases=()
1177}
1178
1179_git-bug_title_edit()
1180{
1181 last_command="git-bug_title_edit"
1182
1183 command_aliases=()
1184
1185 commands=()
1186
1187 flags=()
1188 two_word_flags=()
1189 local_nonpersistent_flags=()
1190 flags_with_completion=()
1191 flags_completion=()
1192
1193 flags+=("--title=")
1194 two_word_flags+=("--title")
1195 two_word_flags+=("-t")
1196 local_nonpersistent_flags+=("--title")
1197 local_nonpersistent_flags+=("--title=")
1198 local_nonpersistent_flags+=("-t")
1199
1200 must_have_one_flag=()
1201 must_have_one_noun=()
1202 noun_aliases=()
1203}
1204
1205_git-bug_title()
1206{
1207 last_command="git-bug_title"
1208
1209 command_aliases=()
1210
1211 commands=()
1212 commands+=("edit")
1213
1214 flags=()
1215 two_word_flags=()
1216 local_nonpersistent_flags=()
1217 flags_with_completion=()
1218 flags_completion=()
1219
1220
1221 must_have_one_flag=()
1222 must_have_one_noun=()
1223 noun_aliases=()
1224}
1225
1226_git-bug_user_adopt()
1227{
1228 last_command="git-bug_user_adopt"
1229
1230 command_aliases=()
1231
1232 commands=()
1233
1234 flags=()
1235 two_word_flags=()
1236 local_nonpersistent_flags=()
1237 flags_with_completion=()
1238 flags_completion=()
1239
1240
1241 must_have_one_flag=()
1242 must_have_one_noun=()
1243 noun_aliases=()
1244}
1245
1246_git-bug_user_create()
1247{
1248 last_command="git-bug_user_create"
1249
1250 command_aliases=()
1251
1252 commands=()
1253
1254 flags=()
1255 two_word_flags=()
1256 local_nonpersistent_flags=()
1257 flags_with_completion=()
1258 flags_completion=()
1259
1260 flags+=("--avatar=")
1261 two_word_flags+=("--avatar")
1262 two_word_flags+=("-a")
1263 local_nonpersistent_flags+=("--avatar")
1264 local_nonpersistent_flags+=("--avatar=")
1265 local_nonpersistent_flags+=("-a")
1266 flags+=("--email=")
1267 two_word_flags+=("--email")
1268 two_word_flags+=("-e")
1269 local_nonpersistent_flags+=("--email")
1270 local_nonpersistent_flags+=("--email=")
1271 local_nonpersistent_flags+=("-e")
1272 flags+=("--name=")
1273 two_word_flags+=("--name")
1274 two_word_flags+=("-n")
1275 local_nonpersistent_flags+=("--name")
1276 local_nonpersistent_flags+=("--name=")
1277 local_nonpersistent_flags+=("-n")
1278
1279 must_have_one_flag=()
1280 must_have_one_noun=()
1281 noun_aliases=()
1282}
1283
1284_git-bug_user_ls()
1285{
1286 last_command="git-bug_user_ls"
1287
1288 command_aliases=()
1289
1290 commands=()
1291
1292 flags=()
1293 two_word_flags=()
1294 local_nonpersistent_flags=()
1295 flags_with_completion=()
1296 flags_completion=()
1297
1298 flags+=("--format=")
1299 two_word_flags+=("--format")
1300 two_word_flags+=("-f")
1301 local_nonpersistent_flags+=("--format")
1302 local_nonpersistent_flags+=("--format=")
1303 local_nonpersistent_flags+=("-f")
1304
1305 must_have_one_flag=()
1306 must_have_one_noun=()
1307 noun_aliases=()
1308}
1309
1310_git-bug_user()
1311{
1312 last_command="git-bug_user"
1313
1314 command_aliases=()
1315
1316 commands=()
1317 commands+=("adopt")
1318 commands+=("create")
1319 commands+=("ls")
1320
1321 flags=()
1322 two_word_flags=()
1323 local_nonpersistent_flags=()
1324 flags_with_completion=()
1325 flags_completion=()
1326
1327 flags+=("--field=")
1328 two_word_flags+=("--field")
1329 two_word_flags+=("-f")
1330 local_nonpersistent_flags+=("--field")
1331 local_nonpersistent_flags+=("--field=")
1332 local_nonpersistent_flags+=("-f")
1333
1334 must_have_one_flag=()
1335 must_have_one_noun=()
1336 noun_aliases=()
1337}
1338
1339_git-bug_version()
1340{
1341 last_command="git-bug_version"
1342
1343 command_aliases=()
1344
1345 commands=()
1346
1347 flags=()
1348 two_word_flags=()
1349 local_nonpersistent_flags=()
1350 flags_with_completion=()
1351 flags_completion=()
1352
1353 flags+=("--number")
1354 flags+=("-n")
1355 local_nonpersistent_flags+=("--number")
1356 local_nonpersistent_flags+=("-n")
1357 flags+=("--commit")
1358 flags+=("-c")
1359 local_nonpersistent_flags+=("--commit")
1360 local_nonpersistent_flags+=("-c")
1361 flags+=("--all")
1362 flags+=("-a")
1363 local_nonpersistent_flags+=("--all")
1364 local_nonpersistent_flags+=("-a")
1365
1366 must_have_one_flag=()
1367 must_have_one_noun=()
1368 noun_aliases=()
1369}
1370
1371_git-bug_webui()
1372{
1373 last_command="git-bug_webui"
1374
1375 command_aliases=()
1376
1377 commands=()
1378
1379 flags=()
1380 two_word_flags=()
1381 local_nonpersistent_flags=()
1382 flags_with_completion=()
1383 flags_completion=()
1384
1385 flags+=("--host=")
1386 two_word_flags+=("--host")
1387 local_nonpersistent_flags+=("--host")
1388 local_nonpersistent_flags+=("--host=")
1389 flags+=("--open")
1390 local_nonpersistent_flags+=("--open")
1391 flags+=("--no-open")
1392 local_nonpersistent_flags+=("--no-open")
1393 flags+=("--port=")
1394 two_word_flags+=("--port")
1395 two_word_flags+=("-p")
1396 local_nonpersistent_flags+=("--port")
1397 local_nonpersistent_flags+=("--port=")
1398 local_nonpersistent_flags+=("-p")
1399 flags+=("--read-only")
1400 local_nonpersistent_flags+=("--read-only")
1401 flags+=("--query=")
1402 two_word_flags+=("--query")
1403 two_word_flags+=("-q")
1404 local_nonpersistent_flags+=("--query")
1405 local_nonpersistent_flags+=("--query=")
1406 local_nonpersistent_flags+=("-q")
1407
1408 must_have_one_flag=()
1409 must_have_one_noun=()
1410 noun_aliases=()
1411}
1412
1413_git-bug_root_command()
1414{
1415 last_command="git-bug"
1416
1417 command_aliases=()
1418
1419 commands=()
1420 commands+=("add")
1421 commands+=("bridge")
1422 commands+=("commands")
1423 commands+=("comment")
1424 commands+=("deselect")
1425 commands+=("label")
1426 commands+=("ls")
1427 commands+=("ls-id")
1428 commands+=("ls-label")
1429 commands+=("pull")
1430 commands+=("push")
1431 commands+=("rm")
1432 commands+=("select")
1433 commands+=("show")
1434 commands+=("status")
1435 commands+=("termui")
1436 if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
1437 command_aliases+=("tui")
1438 aliashash["tui"]="termui"
1439 fi
1440 commands+=("title")
1441 commands+=("user")
1442 commands+=("version")
1443 commands+=("webui")
1444
1445 flags=()
1446 two_word_flags=()
1447 local_nonpersistent_flags=()
1448 flags_with_completion=()
1449 flags_completion=()
1450
1451
1452 must_have_one_flag=()
1453 must_have_one_noun=()
1454 noun_aliases=()
1455}
1456
1457__start_git-bug()
1458{
1459 local cur prev words cword
1460 declare -A flaghash 2>/dev/null || :
1461 declare -A aliashash 2>/dev/null || :
1462 if declare -F _init_completion >/dev/null 2>&1; then
1463 _init_completion -s || return
1464 else
1465 __git-bug_init_completion -n "=" || return
1466 fi
1467
1468 local c=0
1469 local flags=()
1470 local two_word_flags=()
1471 local local_nonpersistent_flags=()
1472 local flags_with_completion=()
1473 local flags_completion=()
1474 local commands=("git-bug")
1475 local must_have_one_flag=()
1476 local must_have_one_noun=()
1477 local has_completion_function
1478 local last_command
1479 local nouns=()
1480
1481 __git-bug_handle_word
1482}
1483
1484if [[ $(type -t compopt) = "builtin" ]]; then
1485 complete -o default -F __start_git-bug git-bug
1486else
1487 complete -o default -o nospace -F __start_git-bug git-bug
1488fi
1489
1490# ex: ts=4 sw=4 et filetype=sh