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-stdin")
 412    local_nonpersistent_flags+=("--token-stdin")
 413    flags+=("--project=")
 414    two_word_flags+=("--project")
 415    two_word_flags+=("-p")
 416    local_nonpersistent_flags+=("--project=")
 417
 418    must_have_one_flag=()
 419    must_have_one_noun=()
 420    noun_aliases=()
 421}
 422
 423_git-bug_bridge_pull()
 424{
 425    last_command="git-bug_bridge_pull"
 426
 427    command_aliases=()
 428
 429    commands=()
 430
 431    flags=()
 432    two_word_flags=()
 433    local_nonpersistent_flags=()
 434    flags_with_completion=()
 435    flags_completion=()
 436
 437    flags+=("--no-resume")
 438    flags+=("-n")
 439    local_nonpersistent_flags+=("--no-resume")
 440    flags+=("--since=")
 441    two_word_flags+=("--since")
 442    two_word_flags+=("-s")
 443    local_nonpersistent_flags+=("--since=")
 444
 445    must_have_one_flag=()
 446    must_have_one_noun=()
 447    noun_aliases=()
 448}
 449
 450_git-bug_bridge_push()
 451{
 452    last_command="git-bug_bridge_push"
 453
 454    command_aliases=()
 455
 456    commands=()
 457
 458    flags=()
 459    two_word_flags=()
 460    local_nonpersistent_flags=()
 461    flags_with_completion=()
 462    flags_completion=()
 463
 464
 465    must_have_one_flag=()
 466    must_have_one_noun=()
 467    noun_aliases=()
 468}
 469
 470_git-bug_bridge_rm()
 471{
 472    last_command="git-bug_bridge_rm"
 473
 474    command_aliases=()
 475
 476    commands=()
 477
 478    flags=()
 479    two_word_flags=()
 480    local_nonpersistent_flags=()
 481    flags_with_completion=()
 482    flags_completion=()
 483
 484
 485    must_have_one_flag=()
 486    must_have_one_noun=()
 487    noun_aliases=()
 488}
 489
 490_git-bug_bridge()
 491{
 492    last_command="git-bug_bridge"
 493
 494    command_aliases=()
 495
 496    commands=()
 497    commands+=("auth")
 498    commands+=("configure")
 499    commands+=("pull")
 500    commands+=("push")
 501    commands+=("rm")
 502
 503    flags=()
 504    two_word_flags=()
 505    local_nonpersistent_flags=()
 506    flags_with_completion=()
 507    flags_completion=()
 508
 509
 510    must_have_one_flag=()
 511    must_have_one_noun=()
 512    noun_aliases=()
 513}
 514
 515_git-bug_commands()
 516{
 517    last_command="git-bug_commands"
 518
 519    command_aliases=()
 520
 521    commands=()
 522
 523    flags=()
 524    two_word_flags=()
 525    local_nonpersistent_flags=()
 526    flags_with_completion=()
 527    flags_completion=()
 528
 529    flags+=("--pretty")
 530    flags+=("-p")
 531    local_nonpersistent_flags+=("--pretty")
 532
 533    must_have_one_flag=()
 534    must_have_one_noun=()
 535    noun_aliases=()
 536}
 537
 538_git-bug_comment_add()
 539{
 540    last_command="git-bug_comment_add"
 541
 542    command_aliases=()
 543
 544    commands=()
 545
 546    flags=()
 547    two_word_flags=()
 548    local_nonpersistent_flags=()
 549    flags_with_completion=()
 550    flags_completion=()
 551
 552    flags+=("--file=")
 553    two_word_flags+=("--file")
 554    two_word_flags+=("-F")
 555    local_nonpersistent_flags+=("--file=")
 556    flags+=("--message=")
 557    two_word_flags+=("--message")
 558    two_word_flags+=("-m")
 559    local_nonpersistent_flags+=("--message=")
 560
 561    must_have_one_flag=()
 562    must_have_one_noun=()
 563    noun_aliases=()
 564}
 565
 566_git-bug_comment()
 567{
 568    last_command="git-bug_comment"
 569
 570    command_aliases=()
 571
 572    commands=()
 573    commands+=("add")
 574
 575    flags=()
 576    two_word_flags=()
 577    local_nonpersistent_flags=()
 578    flags_with_completion=()
 579    flags_completion=()
 580
 581
 582    must_have_one_flag=()
 583    must_have_one_noun=()
 584    noun_aliases=()
 585}
 586
 587_git-bug_deselect()
 588{
 589    last_command="git-bug_deselect"
 590
 591    command_aliases=()
 592
 593    commands=()
 594
 595    flags=()
 596    two_word_flags=()
 597    local_nonpersistent_flags=()
 598    flags_with_completion=()
 599    flags_completion=()
 600
 601
 602    must_have_one_flag=()
 603    must_have_one_noun=()
 604    noun_aliases=()
 605}
 606
 607_git-bug_label_add()
 608{
 609    last_command="git-bug_label_add"
 610
 611    command_aliases=()
 612
 613    commands=()
 614
 615    flags=()
 616    two_word_flags=()
 617    local_nonpersistent_flags=()
 618    flags_with_completion=()
 619    flags_completion=()
 620
 621
 622    must_have_one_flag=()
 623    must_have_one_noun=()
 624    noun_aliases=()
 625}
 626
 627_git-bug_label_rm()
 628{
 629    last_command="git-bug_label_rm"
 630
 631    command_aliases=()
 632
 633    commands=()
 634
 635    flags=()
 636    two_word_flags=()
 637    local_nonpersistent_flags=()
 638    flags_with_completion=()
 639    flags_completion=()
 640
 641
 642    must_have_one_flag=()
 643    must_have_one_noun=()
 644    noun_aliases=()
 645}
 646
 647_git-bug_label()
 648{
 649    last_command="git-bug_label"
 650
 651    command_aliases=()
 652
 653    commands=()
 654    commands+=("add")
 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_ls()
 670{
 671    last_command="git-bug_ls"
 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+=("--status=")
 684    two_word_flags+=("--status")
 685    two_word_flags+=("-s")
 686    local_nonpersistent_flags+=("--status=")
 687    flags+=("--author=")
 688    two_word_flags+=("--author")
 689    two_word_flags+=("-a")
 690    local_nonpersistent_flags+=("--author=")
 691    flags+=("--participant=")
 692    two_word_flags+=("--participant")
 693    two_word_flags+=("-p")
 694    local_nonpersistent_flags+=("--participant=")
 695    flags+=("--actor=")
 696    two_word_flags+=("--actor")
 697    two_word_flags+=("-A")
 698    local_nonpersistent_flags+=("--actor=")
 699    flags+=("--label=")
 700    two_word_flags+=("--label")
 701    two_word_flags+=("-l")
 702    local_nonpersistent_flags+=("--label=")
 703    flags+=("--title=")
 704    two_word_flags+=("--title")
 705    two_word_flags+=("-t")
 706    local_nonpersistent_flags+=("--title=")
 707    flags+=("--no=")
 708    two_word_flags+=("--no")
 709    two_word_flags+=("-n")
 710    local_nonpersistent_flags+=("--no=")
 711    flags+=("--by=")
 712    two_word_flags+=("--by")
 713    two_word_flags+=("-b")
 714    local_nonpersistent_flags+=("--by=")
 715    flags+=("--direction=")
 716    two_word_flags+=("--direction")
 717    two_word_flags+=("-d")
 718    local_nonpersistent_flags+=("--direction=")
 719
 720    must_have_one_flag=()
 721    must_have_one_noun=()
 722    noun_aliases=()
 723}
 724
 725_git-bug_ls-id()
 726{
 727    last_command="git-bug_ls-id"
 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
 740    must_have_one_flag=()
 741    must_have_one_noun=()
 742    noun_aliases=()
 743}
 744
 745_git-bug_ls-label()
 746{
 747    last_command="git-bug_ls-label"
 748
 749    command_aliases=()
 750
 751    commands=()
 752
 753    flags=()
 754    two_word_flags=()
 755    local_nonpersistent_flags=()
 756    flags_with_completion=()
 757    flags_completion=()
 758
 759
 760    must_have_one_flag=()
 761    must_have_one_noun=()
 762    noun_aliases=()
 763}
 764
 765_git-bug_pull()
 766{
 767    last_command="git-bug_pull"
 768
 769    command_aliases=()
 770
 771    commands=()
 772
 773    flags=()
 774    two_word_flags=()
 775    local_nonpersistent_flags=()
 776    flags_with_completion=()
 777    flags_completion=()
 778
 779
 780    must_have_one_flag=()
 781    must_have_one_noun=()
 782    noun_aliases=()
 783}
 784
 785_git-bug_push()
 786{
 787    last_command="git-bug_push"
 788
 789    command_aliases=()
 790
 791    commands=()
 792
 793    flags=()
 794    two_word_flags=()
 795    local_nonpersistent_flags=()
 796    flags_with_completion=()
 797    flags_completion=()
 798
 799
 800    must_have_one_flag=()
 801    must_have_one_noun=()
 802    noun_aliases=()
 803}
 804
 805_git-bug_select()
 806{
 807    last_command="git-bug_select"
 808
 809    command_aliases=()
 810
 811    commands=()
 812
 813    flags=()
 814    two_word_flags=()
 815    local_nonpersistent_flags=()
 816    flags_with_completion=()
 817    flags_completion=()
 818
 819
 820    must_have_one_flag=()
 821    must_have_one_noun=()
 822    noun_aliases=()
 823}
 824
 825_git-bug_show()
 826{
 827    last_command="git-bug_show"
 828
 829    command_aliases=()
 830
 831    commands=()
 832
 833    flags=()
 834    two_word_flags=()
 835    local_nonpersistent_flags=()
 836    flags_with_completion=()
 837    flags_completion=()
 838
 839    flags+=("--field=")
 840    two_word_flags+=("--field")
 841    two_word_flags+=("-f")
 842    local_nonpersistent_flags+=("--field=")
 843
 844    must_have_one_flag=()
 845    must_have_one_noun=()
 846    noun_aliases=()
 847}
 848
 849_git-bug_status_close()
 850{
 851    last_command="git-bug_status_close"
 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_status_open()
 870{
 871    last_command="git-bug_status_open"
 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_status()
 890{
 891    last_command="git-bug_status"
 892
 893    command_aliases=()
 894
 895    commands=()
 896    commands+=("close")
 897    commands+=("open")
 898
 899    flags=()
 900    two_word_flags=()
 901    local_nonpersistent_flags=()
 902    flags_with_completion=()
 903    flags_completion=()
 904
 905
 906    must_have_one_flag=()
 907    must_have_one_noun=()
 908    noun_aliases=()
 909}
 910
 911_git-bug_termui()
 912{
 913    last_command="git-bug_termui"
 914
 915    command_aliases=()
 916
 917    commands=()
 918
 919    flags=()
 920    two_word_flags=()
 921    local_nonpersistent_flags=()
 922    flags_with_completion=()
 923    flags_completion=()
 924
 925
 926    must_have_one_flag=()
 927    must_have_one_noun=()
 928    noun_aliases=()
 929}
 930
 931_git-bug_title_edit()
 932{
 933    last_command="git-bug_title_edit"
 934
 935    command_aliases=()
 936
 937    commands=()
 938
 939    flags=()
 940    two_word_flags=()
 941    local_nonpersistent_flags=()
 942    flags_with_completion=()
 943    flags_completion=()
 944
 945    flags+=("--title=")
 946    two_word_flags+=("--title")
 947    two_word_flags+=("-t")
 948    local_nonpersistent_flags+=("--title=")
 949
 950    must_have_one_flag=()
 951    must_have_one_noun=()
 952    noun_aliases=()
 953}
 954
 955_git-bug_title()
 956{
 957    last_command="git-bug_title"
 958
 959    command_aliases=()
 960
 961    commands=()
 962    commands+=("edit")
 963
 964    flags=()
 965    two_word_flags=()
 966    local_nonpersistent_flags=()
 967    flags_with_completion=()
 968    flags_completion=()
 969
 970
 971    must_have_one_flag=()
 972    must_have_one_noun=()
 973    noun_aliases=()
 974}
 975
 976_git-bug_user_adopt()
 977{
 978    last_command="git-bug_user_adopt"
 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_user_create()
 997{
 998    last_command="git-bug_user_create"
 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_user_ls()
1017{
1018    last_command="git-bug_user_ls"
1019
1020    command_aliases=()
1021
1022    commands=()
1023
1024    flags=()
1025    two_word_flags=()
1026    local_nonpersistent_flags=()
1027    flags_with_completion=()
1028    flags_completion=()
1029
1030
1031    must_have_one_flag=()
1032    must_have_one_noun=()
1033    noun_aliases=()
1034}
1035
1036_git-bug_user()
1037{
1038    last_command="git-bug_user"
1039
1040    command_aliases=()
1041
1042    commands=()
1043    commands+=("adopt")
1044    commands+=("create")
1045    commands+=("ls")
1046
1047    flags=()
1048    two_word_flags=()
1049    local_nonpersistent_flags=()
1050    flags_with_completion=()
1051    flags_completion=()
1052
1053    flags+=("--field=")
1054    two_word_flags+=("--field")
1055    two_word_flags+=("-f")
1056    local_nonpersistent_flags+=("--field=")
1057
1058    must_have_one_flag=()
1059    must_have_one_noun=()
1060    noun_aliases=()
1061}
1062
1063_git-bug_version()
1064{
1065    last_command="git-bug_version"
1066
1067    command_aliases=()
1068
1069    commands=()
1070
1071    flags=()
1072    two_word_flags=()
1073    local_nonpersistent_flags=()
1074    flags_with_completion=()
1075    flags_completion=()
1076
1077    flags+=("--number")
1078    flags+=("-n")
1079    local_nonpersistent_flags+=("--number")
1080    flags+=("--commit")
1081    flags+=("-c")
1082    local_nonpersistent_flags+=("--commit")
1083    flags+=("--all")
1084    flags+=("-a")
1085    local_nonpersistent_flags+=("--all")
1086
1087    must_have_one_flag=()
1088    must_have_one_noun=()
1089    noun_aliases=()
1090}
1091
1092_git-bug_webui()
1093{
1094    last_command="git-bug_webui"
1095
1096    command_aliases=()
1097
1098    commands=()
1099
1100    flags=()
1101    two_word_flags=()
1102    local_nonpersistent_flags=()
1103    flags_with_completion=()
1104    flags_completion=()
1105
1106    flags+=("--open")
1107    local_nonpersistent_flags+=("--open")
1108    flags+=("--no-open")
1109    local_nonpersistent_flags+=("--no-open")
1110    flags+=("--port=")
1111    two_word_flags+=("--port")
1112    two_word_flags+=("-p")
1113    local_nonpersistent_flags+=("--port=")
1114
1115    must_have_one_flag=()
1116    must_have_one_noun=()
1117    noun_aliases=()
1118}
1119
1120_git-bug_root_command()
1121{
1122    last_command="git-bug"
1123
1124    command_aliases=()
1125
1126    commands=()
1127    commands+=("add")
1128    commands+=("bridge")
1129    commands+=("commands")
1130    commands+=("comment")
1131    commands+=("deselect")
1132    commands+=("label")
1133    commands+=("ls")
1134    commands+=("ls-id")
1135    commands+=("ls-label")
1136    commands+=("pull")
1137    commands+=("push")
1138    commands+=("select")
1139    commands+=("show")
1140    commands+=("status")
1141    commands+=("termui")
1142    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
1143        command_aliases+=("tui")
1144        aliashash["tui"]="termui"
1145    fi
1146    commands+=("title")
1147    commands+=("user")
1148    commands+=("version")
1149    commands+=("webui")
1150
1151    flags=()
1152    two_word_flags=()
1153    local_nonpersistent_flags=()
1154    flags_with_completion=()
1155    flags_completion=()
1156
1157
1158    must_have_one_flag=()
1159    must_have_one_noun=()
1160    noun_aliases=()
1161}
1162
1163__start_git-bug()
1164{
1165    local cur prev words cword
1166    declare -A flaghash 2>/dev/null || :
1167    declare -A aliashash 2>/dev/null || :
1168    if declare -F _init_completion >/dev/null 2>&1; then
1169        _init_completion -s || return
1170    else
1171        __git-bug_init_completion -n "=" || return
1172    fi
1173
1174    local c=0
1175    local flags=()
1176    local two_word_flags=()
1177    local local_nonpersistent_flags=()
1178    local flags_with_completion=()
1179    local flags_completion=()
1180    local commands=("git-bug")
1181    local must_have_one_flag=()
1182    local must_have_one_noun=()
1183    local last_command
1184    local nouns=()
1185
1186    __git-bug_handle_word
1187}
1188
1189if [[ $(type -t compopt) = "builtin" ]]; then
1190    complete -o default -F __start_git-bug git-bug
1191else
1192    complete -o default -o nospace -F __start_git-bug git-bug
1193fi
1194
1195# ex: ts=4 sw=4 et filetype=sh