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