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