git-bug

   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+=("--participant=")
 888    two_word_flags+=("--participant")
 889    two_word_flags+=("-p")
 890    local_nonpersistent_flags+=("--participant")
 891    local_nonpersistent_flags+=("--participant=")
 892    local_nonpersistent_flags+=("-p")
 893    flags+=("--actor=")
 894    two_word_flags+=("--actor")
 895    two_word_flags+=("-A")
 896    local_nonpersistent_flags+=("--actor")
 897    local_nonpersistent_flags+=("--actor=")
 898    local_nonpersistent_flags+=("-A")
 899    flags+=("--label=")
 900    two_word_flags+=("--label")
 901    two_word_flags+=("-l")
 902    local_nonpersistent_flags+=("--label")
 903    local_nonpersistent_flags+=("--label=")
 904    local_nonpersistent_flags+=("-l")
 905    flags+=("--title=")
 906    two_word_flags+=("--title")
 907    two_word_flags+=("-t")
 908    local_nonpersistent_flags+=("--title")
 909    local_nonpersistent_flags+=("--title=")
 910    local_nonpersistent_flags+=("-t")
 911    flags+=("--no=")
 912    two_word_flags+=("--no")
 913    two_word_flags+=("-n")
 914    local_nonpersistent_flags+=("--no")
 915    local_nonpersistent_flags+=("--no=")
 916    local_nonpersistent_flags+=("-n")
 917    flags+=("--by=")
 918    two_word_flags+=("--by")
 919    two_word_flags+=("-b")
 920    local_nonpersistent_flags+=("--by")
 921    local_nonpersistent_flags+=("--by=")
 922    local_nonpersistent_flags+=("-b")
 923    flags+=("--direction=")
 924    two_word_flags+=("--direction")
 925    two_word_flags+=("-d")
 926    local_nonpersistent_flags+=("--direction")
 927    local_nonpersistent_flags+=("--direction=")
 928    local_nonpersistent_flags+=("-d")
 929    flags+=("--format=")
 930    two_word_flags+=("--format")
 931    two_word_flags+=("-f")
 932    local_nonpersistent_flags+=("--format")
 933    local_nonpersistent_flags+=("--format=")
 934    local_nonpersistent_flags+=("-f")
 935
 936    must_have_one_flag=()
 937    must_have_one_noun=()
 938    noun_aliases=()
 939}
 940
 941_git-bug_ls-id()
 942{
 943    last_command="git-bug_ls-id"
 944
 945    command_aliases=()
 946
 947    commands=()
 948
 949    flags=()
 950    two_word_flags=()
 951    local_nonpersistent_flags=()
 952    flags_with_completion=()
 953    flags_completion=()
 954
 955
 956    must_have_one_flag=()
 957    must_have_one_noun=()
 958    noun_aliases=()
 959}
 960
 961_git-bug_ls-label()
 962{
 963    last_command="git-bug_ls-label"
 964
 965    command_aliases=()
 966
 967    commands=()
 968
 969    flags=()
 970    two_word_flags=()
 971    local_nonpersistent_flags=()
 972    flags_with_completion=()
 973    flags_completion=()
 974
 975
 976    must_have_one_flag=()
 977    must_have_one_noun=()
 978    noun_aliases=()
 979}
 980
 981_git-bug_pull()
 982{
 983    last_command="git-bug_pull"
 984
 985    command_aliases=()
 986
 987    commands=()
 988
 989    flags=()
 990    two_word_flags=()
 991    local_nonpersistent_flags=()
 992    flags_with_completion=()
 993    flags_completion=()
 994
 995
 996    must_have_one_flag=()
 997    must_have_one_noun=()
 998    noun_aliases=()
 999}
1000
1001_git-bug_push()
1002{
1003    last_command="git-bug_push"
1004
1005    command_aliases=()
1006
1007    commands=()
1008
1009    flags=()
1010    two_word_flags=()
1011    local_nonpersistent_flags=()
1012    flags_with_completion=()
1013    flags_completion=()
1014
1015
1016    must_have_one_flag=()
1017    must_have_one_noun=()
1018    noun_aliases=()
1019}
1020
1021_git-bug_rm()
1022{
1023    last_command="git-bug_rm"
1024
1025    command_aliases=()
1026
1027    commands=()
1028
1029    flags=()
1030    two_word_flags=()
1031    local_nonpersistent_flags=()
1032    flags_with_completion=()
1033    flags_completion=()
1034
1035
1036    must_have_one_flag=()
1037    must_have_one_noun=()
1038    noun_aliases=()
1039}
1040
1041_git-bug_select()
1042{
1043    last_command="git-bug_select"
1044
1045    command_aliases=()
1046
1047    commands=()
1048
1049    flags=()
1050    two_word_flags=()
1051    local_nonpersistent_flags=()
1052    flags_with_completion=()
1053    flags_completion=()
1054
1055
1056    must_have_one_flag=()
1057    must_have_one_noun=()
1058    noun_aliases=()
1059}
1060
1061_git-bug_show()
1062{
1063    last_command="git-bug_show"
1064
1065    command_aliases=()
1066
1067    commands=()
1068
1069    flags=()
1070    two_word_flags=()
1071    local_nonpersistent_flags=()
1072    flags_with_completion=()
1073    flags_completion=()
1074
1075    flags+=("--field=")
1076    two_word_flags+=("--field")
1077    local_nonpersistent_flags+=("--field")
1078    local_nonpersistent_flags+=("--field=")
1079    flags+=("--format=")
1080    two_word_flags+=("--format")
1081    two_word_flags+=("-f")
1082    local_nonpersistent_flags+=("--format")
1083    local_nonpersistent_flags+=("--format=")
1084    local_nonpersistent_flags+=("-f")
1085
1086    must_have_one_flag=()
1087    must_have_one_noun=()
1088    noun_aliases=()
1089}
1090
1091_git-bug_status_close()
1092{
1093    last_command="git-bug_status_close"
1094
1095    command_aliases=()
1096
1097    commands=()
1098
1099    flags=()
1100    two_word_flags=()
1101    local_nonpersistent_flags=()
1102    flags_with_completion=()
1103    flags_completion=()
1104
1105
1106    must_have_one_flag=()
1107    must_have_one_noun=()
1108    noun_aliases=()
1109}
1110
1111_git-bug_status_open()
1112{
1113    last_command="git-bug_status_open"
1114
1115    command_aliases=()
1116
1117    commands=()
1118
1119    flags=()
1120    two_word_flags=()
1121    local_nonpersistent_flags=()
1122    flags_with_completion=()
1123    flags_completion=()
1124
1125
1126    must_have_one_flag=()
1127    must_have_one_noun=()
1128    noun_aliases=()
1129}
1130
1131_git-bug_status()
1132{
1133    last_command="git-bug_status"
1134
1135    command_aliases=()
1136
1137    commands=()
1138    commands+=("close")
1139    commands+=("open")
1140
1141    flags=()
1142    two_word_flags=()
1143    local_nonpersistent_flags=()
1144    flags_with_completion=()
1145    flags_completion=()
1146
1147
1148    must_have_one_flag=()
1149    must_have_one_noun=()
1150    noun_aliases=()
1151}
1152
1153_git-bug_termui()
1154{
1155    last_command="git-bug_termui"
1156
1157    command_aliases=()
1158
1159    commands=()
1160
1161    flags=()
1162    two_word_flags=()
1163    local_nonpersistent_flags=()
1164    flags_with_completion=()
1165    flags_completion=()
1166
1167
1168    must_have_one_flag=()
1169    must_have_one_noun=()
1170    noun_aliases=()
1171}
1172
1173_git-bug_title_edit()
1174{
1175    last_command="git-bug_title_edit"
1176
1177    command_aliases=()
1178
1179    commands=()
1180
1181    flags=()
1182    two_word_flags=()
1183    local_nonpersistent_flags=()
1184    flags_with_completion=()
1185    flags_completion=()
1186
1187    flags+=("--title=")
1188    two_word_flags+=("--title")
1189    two_word_flags+=("-t")
1190    local_nonpersistent_flags+=("--title")
1191    local_nonpersistent_flags+=("--title=")
1192    local_nonpersistent_flags+=("-t")
1193
1194    must_have_one_flag=()
1195    must_have_one_noun=()
1196    noun_aliases=()
1197}
1198
1199_git-bug_title()
1200{
1201    last_command="git-bug_title"
1202
1203    command_aliases=()
1204
1205    commands=()
1206    commands+=("edit")
1207
1208    flags=()
1209    two_word_flags=()
1210    local_nonpersistent_flags=()
1211    flags_with_completion=()
1212    flags_completion=()
1213
1214
1215    must_have_one_flag=()
1216    must_have_one_noun=()
1217    noun_aliases=()
1218}
1219
1220_git-bug_user_adopt()
1221{
1222    last_command="git-bug_user_adopt"
1223
1224    command_aliases=()
1225
1226    commands=()
1227
1228    flags=()
1229    two_word_flags=()
1230    local_nonpersistent_flags=()
1231    flags_with_completion=()
1232    flags_completion=()
1233
1234
1235    must_have_one_flag=()
1236    must_have_one_noun=()
1237    noun_aliases=()
1238}
1239
1240_git-bug_user_create()
1241{
1242    last_command="git-bug_user_create"
1243
1244    command_aliases=()
1245
1246    commands=()
1247
1248    flags=()
1249    two_word_flags=()
1250    local_nonpersistent_flags=()
1251    flags_with_completion=()
1252    flags_completion=()
1253
1254
1255    must_have_one_flag=()
1256    must_have_one_noun=()
1257    noun_aliases=()
1258}
1259
1260_git-bug_user_ls()
1261{
1262    last_command="git-bug_user_ls"
1263
1264    command_aliases=()
1265
1266    commands=()
1267
1268    flags=()
1269    two_word_flags=()
1270    local_nonpersistent_flags=()
1271    flags_with_completion=()
1272    flags_completion=()
1273
1274    flags+=("--format=")
1275    two_word_flags+=("--format")
1276    two_word_flags+=("-f")
1277    local_nonpersistent_flags+=("--format")
1278    local_nonpersistent_flags+=("--format=")
1279    local_nonpersistent_flags+=("-f")
1280
1281    must_have_one_flag=()
1282    must_have_one_noun=()
1283    noun_aliases=()
1284}
1285
1286_git-bug_user()
1287{
1288    last_command="git-bug_user"
1289
1290    command_aliases=()
1291
1292    commands=()
1293    commands+=("adopt")
1294    commands+=("create")
1295    commands+=("ls")
1296
1297    flags=()
1298    two_word_flags=()
1299    local_nonpersistent_flags=()
1300    flags_with_completion=()
1301    flags_completion=()
1302
1303    flags+=("--field=")
1304    two_word_flags+=("--field")
1305    two_word_flags+=("-f")
1306    local_nonpersistent_flags+=("--field")
1307    local_nonpersistent_flags+=("--field=")
1308    local_nonpersistent_flags+=("-f")
1309
1310    must_have_one_flag=()
1311    must_have_one_noun=()
1312    noun_aliases=()
1313}
1314
1315_git-bug_version()
1316{
1317    last_command="git-bug_version"
1318
1319    command_aliases=()
1320
1321    commands=()
1322
1323    flags=()
1324    two_word_flags=()
1325    local_nonpersistent_flags=()
1326    flags_with_completion=()
1327    flags_completion=()
1328
1329    flags+=("--number")
1330    flags+=("-n")
1331    local_nonpersistent_flags+=("--number")
1332    local_nonpersistent_flags+=("-n")
1333    flags+=("--commit")
1334    flags+=("-c")
1335    local_nonpersistent_flags+=("--commit")
1336    local_nonpersistent_flags+=("-c")
1337    flags+=("--all")
1338    flags+=("-a")
1339    local_nonpersistent_flags+=("--all")
1340    local_nonpersistent_flags+=("-a")
1341
1342    must_have_one_flag=()
1343    must_have_one_noun=()
1344    noun_aliases=()
1345}
1346
1347_git-bug_webui()
1348{
1349    last_command="git-bug_webui"
1350
1351    command_aliases=()
1352
1353    commands=()
1354
1355    flags=()
1356    two_word_flags=()
1357    local_nonpersistent_flags=()
1358    flags_with_completion=()
1359    flags_completion=()
1360
1361    flags+=("--open")
1362    local_nonpersistent_flags+=("--open")
1363    flags+=("--no-open")
1364    local_nonpersistent_flags+=("--no-open")
1365    flags+=("--port=")
1366    two_word_flags+=("--port")
1367    two_word_flags+=("-p")
1368    local_nonpersistent_flags+=("--port")
1369    local_nonpersistent_flags+=("--port=")
1370    local_nonpersistent_flags+=("-p")
1371    flags+=("--read-only")
1372    local_nonpersistent_flags+=("--read-only")
1373
1374    must_have_one_flag=()
1375    must_have_one_noun=()
1376    noun_aliases=()
1377}
1378
1379_git-bug_root_command()
1380{
1381    last_command="git-bug"
1382
1383    command_aliases=()
1384
1385    commands=()
1386    commands+=("add")
1387    commands+=("bridge")
1388    commands+=("commands")
1389    commands+=("comment")
1390    commands+=("deselect")
1391    commands+=("label")
1392    commands+=("ls")
1393    commands+=("ls-id")
1394    commands+=("ls-label")
1395    commands+=("pull")
1396    commands+=("push")
1397    commands+=("rm")
1398    commands+=("select")
1399    commands+=("show")
1400    commands+=("status")
1401    commands+=("termui")
1402    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
1403        command_aliases+=("tui")
1404        aliashash["tui"]="termui"
1405    fi
1406    commands+=("title")
1407    commands+=("user")
1408    commands+=("version")
1409    commands+=("webui")
1410
1411    flags=()
1412    two_word_flags=()
1413    local_nonpersistent_flags=()
1414    flags_with_completion=()
1415    flags_completion=()
1416
1417
1418    must_have_one_flag=()
1419    must_have_one_noun=()
1420    noun_aliases=()
1421}
1422
1423__start_git-bug()
1424{
1425    local cur prev words cword
1426    declare -A flaghash 2>/dev/null || :
1427    declare -A aliashash 2>/dev/null || :
1428    if declare -F _init_completion >/dev/null 2>&1; then
1429        _init_completion -s || return
1430    else
1431        __git-bug_init_completion -n "=" || return
1432    fi
1433
1434    local c=0
1435    local flags=()
1436    local two_word_flags=()
1437    local local_nonpersistent_flags=()
1438    local flags_with_completion=()
1439    local flags_completion=()
1440    local commands=("git-bug")
1441    local must_have_one_flag=()
1442    local must_have_one_noun=()
1443    local has_completion_function
1444    local last_command
1445    local nouns=()
1446
1447    __git-bug_handle_word
1448}
1449
1450if [[ $(type -t compopt) = "builtin" ]]; then
1451    complete -o default -F __start_git-bug git-bug
1452else
1453    complete -o default -o nospace -F __start_git-bug git-bug
1454fi
1455
1456# ex: ts=4 sw=4 et filetype=sh