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 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_edit()
 658{
 659    last_command="git-bug_comment_edit"
 660
 661    command_aliases=()
 662
 663    commands=()
 664
 665    flags=()
 666    two_word_flags=()
 667    local_nonpersistent_flags=()
 668    flags_with_completion=()
 669    flags_completion=()
 670
 671    flags+=("--file=")
 672    two_word_flags+=("--file")
 673    two_word_flags+=("-F")
 674    local_nonpersistent_flags+=("--file=")
 675    flags+=("--message=")
 676    two_word_flags+=("--message")
 677    two_word_flags+=("-m")
 678    local_nonpersistent_flags+=("--message=")
 679
 680    must_have_one_flag=()
 681    must_have_one_noun=()
 682    noun_aliases=()
 683}
 684
 685_git-bug_comment()
 686{
 687    last_command="git-bug_comment"
 688
 689    command_aliases=()
 690
 691    commands=()
 692    commands+=("add")
 693    commands+=("edit")
 694
 695    flags=()
 696    two_word_flags=()
 697    local_nonpersistent_flags=()
 698    flags_with_completion=()
 699    flags_completion=()
 700
 701
 702    must_have_one_flag=()
 703    must_have_one_noun=()
 704    noun_aliases=()
 705}
 706
 707_git-bug_deselect()
 708{
 709    last_command="git-bug_deselect"
 710
 711    command_aliases=()
 712
 713    commands=()
 714
 715    flags=()
 716    two_word_flags=()
 717    local_nonpersistent_flags=()
 718    flags_with_completion=()
 719    flags_completion=()
 720
 721
 722    must_have_one_flag=()
 723    must_have_one_noun=()
 724    noun_aliases=()
 725}
 726
 727_git-bug_label_add()
 728{
 729    last_command="git-bug_label_add"
 730
 731    command_aliases=()
 732
 733    commands=()
 734
 735    flags=()
 736    two_word_flags=()
 737    local_nonpersistent_flags=()
 738    flags_with_completion=()
 739    flags_completion=()
 740
 741
 742    must_have_one_flag=()
 743    must_have_one_noun=()
 744    noun_aliases=()
 745}
 746
 747_git-bug_label_rm()
 748{
 749    last_command="git-bug_label_rm"
 750
 751    command_aliases=()
 752
 753    commands=()
 754
 755    flags=()
 756    two_word_flags=()
 757    local_nonpersistent_flags=()
 758    flags_with_completion=()
 759    flags_completion=()
 760
 761
 762    must_have_one_flag=()
 763    must_have_one_noun=()
 764    noun_aliases=()
 765}
 766
 767_git-bug_label()
 768{
 769    last_command="git-bug_label"
 770
 771    command_aliases=()
 772
 773    commands=()
 774    commands+=("add")
 775    commands+=("rm")
 776
 777    flags=()
 778    two_word_flags=()
 779    local_nonpersistent_flags=()
 780    flags_with_completion=()
 781    flags_completion=()
 782
 783
 784    must_have_one_flag=()
 785    must_have_one_noun=()
 786    noun_aliases=()
 787}
 788
 789_git-bug_ls()
 790{
 791    last_command="git-bug_ls"
 792
 793    command_aliases=()
 794
 795    commands=()
 796
 797    flags=()
 798    two_word_flags=()
 799    local_nonpersistent_flags=()
 800    flags_with_completion=()
 801    flags_completion=()
 802
 803    flags+=("--status=")
 804    two_word_flags+=("--status")
 805    two_word_flags+=("-s")
 806    local_nonpersistent_flags+=("--status=")
 807    flags+=("--author=")
 808    two_word_flags+=("--author")
 809    two_word_flags+=("-a")
 810    local_nonpersistent_flags+=("--author=")
 811    flags+=("--participant=")
 812    two_word_flags+=("--participant")
 813    two_word_flags+=("-p")
 814    local_nonpersistent_flags+=("--participant=")
 815    flags+=("--actor=")
 816    two_word_flags+=("--actor")
 817    two_word_flags+=("-A")
 818    local_nonpersistent_flags+=("--actor=")
 819    flags+=("--label=")
 820    two_word_flags+=("--label")
 821    two_word_flags+=("-l")
 822    local_nonpersistent_flags+=("--label=")
 823    flags+=("--title=")
 824    two_word_flags+=("--title")
 825    two_word_flags+=("-t")
 826    local_nonpersistent_flags+=("--title=")
 827    flags+=("--no=")
 828    two_word_flags+=("--no")
 829    two_word_flags+=("-n")
 830    local_nonpersistent_flags+=("--no=")
 831    flags+=("--by=")
 832    two_word_flags+=("--by")
 833    two_word_flags+=("-b")
 834    local_nonpersistent_flags+=("--by=")
 835    flags+=("--direction=")
 836    two_word_flags+=("--direction")
 837    two_word_flags+=("-d")
 838    local_nonpersistent_flags+=("--direction=")
 839    flags+=("--format=")
 840    two_word_flags+=("--format")
 841    two_word_flags+=("-f")
 842    local_nonpersistent_flags+=("--format=")
 843
 844    must_have_one_flag=()
 845    must_have_one_noun=()
 846    noun_aliases=()
 847}
 848
 849_git-bug_ls-id()
 850{
 851    last_command="git-bug_ls-id"
 852
 853    command_aliases=()
 854
 855    commands=()
 856
 857    flags=()
 858    two_word_flags=()
 859    local_nonpersistent_flags=()
 860    flags_with_completion=()
 861    flags_completion=()
 862
 863
 864    must_have_one_flag=()
 865    must_have_one_noun=()
 866    noun_aliases=()
 867}
 868
 869_git-bug_ls-label()
 870{
 871    last_command="git-bug_ls-label"
 872
 873    command_aliases=()
 874
 875    commands=()
 876
 877    flags=()
 878    two_word_flags=()
 879    local_nonpersistent_flags=()
 880    flags_with_completion=()
 881    flags_completion=()
 882
 883
 884    must_have_one_flag=()
 885    must_have_one_noun=()
 886    noun_aliases=()
 887}
 888
 889_git-bug_pull()
 890{
 891    last_command="git-bug_pull"
 892
 893    command_aliases=()
 894
 895    commands=()
 896
 897    flags=()
 898    two_word_flags=()
 899    local_nonpersistent_flags=()
 900    flags_with_completion=()
 901    flags_completion=()
 902
 903
 904    must_have_one_flag=()
 905    must_have_one_noun=()
 906    noun_aliases=()
 907}
 908
 909_git-bug_push()
 910{
 911    last_command="git-bug_push"
 912
 913    command_aliases=()
 914
 915    commands=()
 916
 917    flags=()
 918    two_word_flags=()
 919    local_nonpersistent_flags=()
 920    flags_with_completion=()
 921    flags_completion=()
 922
 923
 924    must_have_one_flag=()
 925    must_have_one_noun=()
 926    noun_aliases=()
 927}
 928
 929_git-bug_select()
 930{
 931    last_command="git-bug_select"
 932
 933    command_aliases=()
 934
 935    commands=()
 936
 937    flags=()
 938    two_word_flags=()
 939    local_nonpersistent_flags=()
 940    flags_with_completion=()
 941    flags_completion=()
 942
 943
 944    must_have_one_flag=()
 945    must_have_one_noun=()
 946    noun_aliases=()
 947}
 948
 949_git-bug_show()
 950{
 951    last_command="git-bug_show"
 952
 953    command_aliases=()
 954
 955    commands=()
 956
 957    flags=()
 958    two_word_flags=()
 959    local_nonpersistent_flags=()
 960    flags_with_completion=()
 961    flags_completion=()
 962
 963    flags+=("--field=")
 964    two_word_flags+=("--field")
 965    local_nonpersistent_flags+=("--field=")
 966    flags+=("--format=")
 967    two_word_flags+=("--format")
 968    two_word_flags+=("-f")
 969    local_nonpersistent_flags+=("--format=")
 970
 971    must_have_one_flag=()
 972    must_have_one_noun=()
 973    noun_aliases=()
 974}
 975
 976_git-bug_status_close()
 977{
 978    last_command="git-bug_status_close"
 979
 980    command_aliases=()
 981
 982    commands=()
 983
 984    flags=()
 985    two_word_flags=()
 986    local_nonpersistent_flags=()
 987    flags_with_completion=()
 988    flags_completion=()
 989
 990
 991    must_have_one_flag=()
 992    must_have_one_noun=()
 993    noun_aliases=()
 994}
 995
 996_git-bug_status_open()
 997{
 998    last_command="git-bug_status_open"
 999
1000    command_aliases=()
1001
1002    commands=()
1003
1004    flags=()
1005    two_word_flags=()
1006    local_nonpersistent_flags=()
1007    flags_with_completion=()
1008    flags_completion=()
1009
1010
1011    must_have_one_flag=()
1012    must_have_one_noun=()
1013    noun_aliases=()
1014}
1015
1016_git-bug_status()
1017{
1018    last_command="git-bug_status"
1019
1020    command_aliases=()
1021
1022    commands=()
1023    commands+=("close")
1024    commands+=("open")
1025
1026    flags=()
1027    two_word_flags=()
1028    local_nonpersistent_flags=()
1029    flags_with_completion=()
1030    flags_completion=()
1031
1032
1033    must_have_one_flag=()
1034    must_have_one_noun=()
1035    noun_aliases=()
1036}
1037
1038_git-bug_termui()
1039{
1040    last_command="git-bug_termui"
1041
1042    command_aliases=()
1043
1044    commands=()
1045
1046    flags=()
1047    two_word_flags=()
1048    local_nonpersistent_flags=()
1049    flags_with_completion=()
1050    flags_completion=()
1051
1052
1053    must_have_one_flag=()
1054    must_have_one_noun=()
1055    noun_aliases=()
1056}
1057
1058_git-bug_title_edit()
1059{
1060    last_command="git-bug_title_edit"
1061
1062    command_aliases=()
1063
1064    commands=()
1065
1066    flags=()
1067    two_word_flags=()
1068    local_nonpersistent_flags=()
1069    flags_with_completion=()
1070    flags_completion=()
1071
1072    flags+=("--title=")
1073    two_word_flags+=("--title")
1074    two_word_flags+=("-t")
1075    local_nonpersistent_flags+=("--title=")
1076
1077    must_have_one_flag=()
1078    must_have_one_noun=()
1079    noun_aliases=()
1080}
1081
1082_git-bug_title()
1083{
1084    last_command="git-bug_title"
1085
1086    command_aliases=()
1087
1088    commands=()
1089    commands+=("edit")
1090
1091    flags=()
1092    two_word_flags=()
1093    local_nonpersistent_flags=()
1094    flags_with_completion=()
1095    flags_completion=()
1096
1097
1098    must_have_one_flag=()
1099    must_have_one_noun=()
1100    noun_aliases=()
1101}
1102
1103_git-bug_user_adopt()
1104{
1105    last_command="git-bug_user_adopt"
1106
1107    command_aliases=()
1108
1109    commands=()
1110
1111    flags=()
1112    two_word_flags=()
1113    local_nonpersistent_flags=()
1114    flags_with_completion=()
1115    flags_completion=()
1116
1117
1118    must_have_one_flag=()
1119    must_have_one_noun=()
1120    noun_aliases=()
1121}
1122
1123_git-bug_user_create()
1124{
1125    last_command="git-bug_user_create"
1126
1127    command_aliases=()
1128
1129    commands=()
1130
1131    flags=()
1132    two_word_flags=()
1133    local_nonpersistent_flags=()
1134    flags_with_completion=()
1135    flags_completion=()
1136
1137
1138    must_have_one_flag=()
1139    must_have_one_noun=()
1140    noun_aliases=()
1141}
1142
1143_git-bug_user_ls()
1144{
1145    last_command="git-bug_user_ls"
1146
1147    command_aliases=()
1148
1149    commands=()
1150
1151    flags=()
1152    two_word_flags=()
1153    local_nonpersistent_flags=()
1154    flags_with_completion=()
1155    flags_completion=()
1156
1157    flags+=("--format=")
1158    two_word_flags+=("--format")
1159    two_word_flags+=("-f")
1160    local_nonpersistent_flags+=("--format=")
1161
1162    must_have_one_flag=()
1163    must_have_one_noun=()
1164    noun_aliases=()
1165}
1166
1167_git-bug_user()
1168{
1169    last_command="git-bug_user"
1170
1171    command_aliases=()
1172
1173    commands=()
1174    commands+=("adopt")
1175    commands+=("create")
1176    commands+=("ls")
1177
1178    flags=()
1179    two_word_flags=()
1180    local_nonpersistent_flags=()
1181    flags_with_completion=()
1182    flags_completion=()
1183
1184    flags+=("--field=")
1185    two_word_flags+=("--field")
1186    two_word_flags+=("-f")
1187    local_nonpersistent_flags+=("--field=")
1188
1189    must_have_one_flag=()
1190    must_have_one_noun=()
1191    noun_aliases=()
1192}
1193
1194_git-bug_version()
1195{
1196    last_command="git-bug_version"
1197
1198    command_aliases=()
1199
1200    commands=()
1201
1202    flags=()
1203    two_word_flags=()
1204    local_nonpersistent_flags=()
1205    flags_with_completion=()
1206    flags_completion=()
1207
1208    flags+=("--number")
1209    flags+=("-n")
1210    local_nonpersistent_flags+=("--number")
1211    flags+=("--commit")
1212    flags+=("-c")
1213    local_nonpersistent_flags+=("--commit")
1214    flags+=("--all")
1215    flags+=("-a")
1216    local_nonpersistent_flags+=("--all")
1217
1218    must_have_one_flag=()
1219    must_have_one_noun=()
1220    noun_aliases=()
1221}
1222
1223_git-bug_webui()
1224{
1225    last_command="git-bug_webui"
1226
1227    command_aliases=()
1228
1229    commands=()
1230
1231    flags=()
1232    two_word_flags=()
1233    local_nonpersistent_flags=()
1234    flags_with_completion=()
1235    flags_completion=()
1236
1237    flags+=("--open")
1238    local_nonpersistent_flags+=("--open")
1239    flags+=("--no-open")
1240    local_nonpersistent_flags+=("--no-open")
1241    flags+=("--port=")
1242    two_word_flags+=("--port")
1243    two_word_flags+=("-p")
1244    local_nonpersistent_flags+=("--port=")
1245    flags+=("--read-only")
1246    local_nonpersistent_flags+=("--read-only")
1247
1248    must_have_one_flag=()
1249    must_have_one_noun=()
1250    noun_aliases=()
1251}
1252
1253_git-bug_root_command()
1254{
1255    last_command="git-bug"
1256
1257    command_aliases=()
1258
1259    commands=()
1260    commands+=("add")
1261    commands+=("bridge")
1262    commands+=("commands")
1263    commands+=("comment")
1264    commands+=("deselect")
1265    commands+=("label")
1266    commands+=("ls")
1267    commands+=("ls-id")
1268    commands+=("ls-label")
1269    commands+=("pull")
1270    commands+=("push")
1271    commands+=("select")
1272    commands+=("show")
1273    commands+=("status")
1274    commands+=("termui")
1275    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
1276        command_aliases+=("tui")
1277        aliashash["tui"]="termui"
1278    fi
1279    commands+=("title")
1280    commands+=("user")
1281    commands+=("version")
1282    commands+=("webui")
1283
1284    flags=()
1285    two_word_flags=()
1286    local_nonpersistent_flags=()
1287    flags_with_completion=()
1288    flags_completion=()
1289
1290
1291    must_have_one_flag=()
1292    must_have_one_noun=()
1293    noun_aliases=()
1294}
1295
1296__start_git-bug()
1297{
1298    local cur prev words cword
1299    declare -A flaghash 2>/dev/null || :
1300    declare -A aliashash 2>/dev/null || :
1301    if declare -F _init_completion >/dev/null 2>&1; then
1302        _init_completion -s || return
1303    else
1304        __git-bug_init_completion -n "=" || return
1305    fi
1306
1307    local c=0
1308    local flags=()
1309    local two_word_flags=()
1310    local local_nonpersistent_flags=()
1311    local flags_with_completion=()
1312    local flags_completion=()
1313    local commands=("git-bug")
1314    local must_have_one_flag=()
1315    local must_have_one_noun=()
1316    local has_completion_function
1317    local last_command
1318    local nouns=()
1319
1320    __git-bug_handle_word
1321}
1322
1323if [[ $(type -t compopt) = "builtin" ]]; then
1324    complete -o default -F __start_git-bug git-bug
1325else
1326    complete -o default -o nospace -F __start_git-bug git-bug
1327fi
1328
1329# ex: ts=4 sw=4 et filetype=sh