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_configure()
 291{
 292    last_command="git-bug_bridge_configure"
 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+=("--name=")
 305    two_word_flags+=("--name")
 306    two_word_flags+=("-n")
 307    local_nonpersistent_flags+=("--name=")
 308    flags+=("--target=")
 309    two_word_flags+=("--target")
 310    two_word_flags+=("-t")
 311    local_nonpersistent_flags+=("--target=")
 312    flags+=("--url=")
 313    two_word_flags+=("--url")
 314    two_word_flags+=("-u")
 315    local_nonpersistent_flags+=("--url=")
 316    flags+=("--owner=")
 317    two_word_flags+=("--owner")
 318    two_word_flags+=("-o")
 319    local_nonpersistent_flags+=("--owner=")
 320    flags+=("--token=")
 321    two_word_flags+=("--token")
 322    two_word_flags+=("-T")
 323    local_nonpersistent_flags+=("--token=")
 324    flags+=("--token-stdin")
 325    local_nonpersistent_flags+=("--token-stdin")
 326    flags+=("--project=")
 327    two_word_flags+=("--project")
 328    two_word_flags+=("-p")
 329    local_nonpersistent_flags+=("--project=")
 330
 331    must_have_one_flag=()
 332    must_have_one_noun=()
 333    noun_aliases=()
 334}
 335
 336_git-bug_bridge_pull()
 337{
 338    last_command="git-bug_bridge_pull"
 339
 340    command_aliases=()
 341
 342    commands=()
 343
 344    flags=()
 345    two_word_flags=()
 346    local_nonpersistent_flags=()
 347    flags_with_completion=()
 348    flags_completion=()
 349
 350    flags+=("--no-resume")
 351    flags+=("-n")
 352    local_nonpersistent_flags+=("--no-resume")
 353    flags+=("--since=")
 354    two_word_flags+=("--since")
 355    two_word_flags+=("-s")
 356    local_nonpersistent_flags+=("--since=")
 357
 358    must_have_one_flag=()
 359    must_have_one_noun=()
 360    noun_aliases=()
 361}
 362
 363_git-bug_bridge_push()
 364{
 365    last_command="git-bug_bridge_push"
 366
 367    command_aliases=()
 368
 369    commands=()
 370
 371    flags=()
 372    two_word_flags=()
 373    local_nonpersistent_flags=()
 374    flags_with_completion=()
 375    flags_completion=()
 376
 377
 378    must_have_one_flag=()
 379    must_have_one_noun=()
 380    noun_aliases=()
 381}
 382
 383_git-bug_bridge_rm()
 384{
 385    last_command="git-bug_bridge_rm"
 386
 387    command_aliases=()
 388
 389    commands=()
 390
 391    flags=()
 392    two_word_flags=()
 393    local_nonpersistent_flags=()
 394    flags_with_completion=()
 395    flags_completion=()
 396
 397
 398    must_have_one_flag=()
 399    must_have_one_noun=()
 400    noun_aliases=()
 401}
 402
 403_git-bug_bridge()
 404{
 405    last_command="git-bug_bridge"
 406
 407    command_aliases=()
 408
 409    commands=()
 410    commands+=("configure")
 411    commands+=("pull")
 412    commands+=("push")
 413    commands+=("rm")
 414
 415    flags=()
 416    two_word_flags=()
 417    local_nonpersistent_flags=()
 418    flags_with_completion=()
 419    flags_completion=()
 420
 421
 422    must_have_one_flag=()
 423    must_have_one_noun=()
 424    noun_aliases=()
 425}
 426
 427_git-bug_commands()
 428{
 429    last_command="git-bug_commands"
 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+=("--pretty")
 442    flags+=("-p")
 443    local_nonpersistent_flags+=("--pretty")
 444
 445    must_have_one_flag=()
 446    must_have_one_noun=()
 447    noun_aliases=()
 448}
 449
 450_git-bug_comment_add()
 451{
 452    last_command="git-bug_comment_add"
 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    flags+=("--file=")
 465    two_word_flags+=("--file")
 466    two_word_flags+=("-F")
 467    local_nonpersistent_flags+=("--file=")
 468    flags+=("--message=")
 469    two_word_flags+=("--message")
 470    two_word_flags+=("-m")
 471    local_nonpersistent_flags+=("--message=")
 472
 473    must_have_one_flag=()
 474    must_have_one_noun=()
 475    noun_aliases=()
 476}
 477
 478_git-bug_comment()
 479{
 480    last_command="git-bug_comment"
 481
 482    command_aliases=()
 483
 484    commands=()
 485    commands+=("add")
 486
 487    flags=()
 488    two_word_flags=()
 489    local_nonpersistent_flags=()
 490    flags_with_completion=()
 491    flags_completion=()
 492
 493
 494    must_have_one_flag=()
 495    must_have_one_noun=()
 496    noun_aliases=()
 497}
 498
 499_git-bug_deselect()
 500{
 501    last_command="git-bug_deselect"
 502
 503    command_aliases=()
 504
 505    commands=()
 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_label_add()
 520{
 521    last_command="git-bug_label_add"
 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
 534    must_have_one_flag=()
 535    must_have_one_noun=()
 536    noun_aliases=()
 537}
 538
 539_git-bug_label_rm()
 540{
 541    last_command="git-bug_label_rm"
 542
 543    command_aliases=()
 544
 545    commands=()
 546
 547    flags=()
 548    two_word_flags=()
 549    local_nonpersistent_flags=()
 550    flags_with_completion=()
 551    flags_completion=()
 552
 553
 554    must_have_one_flag=()
 555    must_have_one_noun=()
 556    noun_aliases=()
 557}
 558
 559_git-bug_label()
 560{
 561    last_command="git-bug_label"
 562
 563    command_aliases=()
 564
 565    commands=()
 566    commands+=("add")
 567    commands+=("rm")
 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_ls()
 582{
 583    last_command="git-bug_ls"
 584
 585    command_aliases=()
 586
 587    commands=()
 588
 589    flags=()
 590    two_word_flags=()
 591    local_nonpersistent_flags=()
 592    flags_with_completion=()
 593    flags_completion=()
 594
 595    flags+=("--status=")
 596    two_word_flags+=("--status")
 597    two_word_flags+=("-s")
 598    local_nonpersistent_flags+=("--status=")
 599    flags+=("--author=")
 600    two_word_flags+=("--author")
 601    two_word_flags+=("-a")
 602    local_nonpersistent_flags+=("--author=")
 603    flags+=("--participant=")
 604    two_word_flags+=("--participant")
 605    two_word_flags+=("-p")
 606    local_nonpersistent_flags+=("--participant=")
 607    flags+=("--actor=")
 608    two_word_flags+=("--actor")
 609    two_word_flags+=("-A")
 610    local_nonpersistent_flags+=("--actor=")
 611    flags+=("--label=")
 612    two_word_flags+=("--label")
 613    two_word_flags+=("-l")
 614    local_nonpersistent_flags+=("--label=")
 615    flags+=("--title=")
 616    two_word_flags+=("--title")
 617    two_word_flags+=("-t")
 618    local_nonpersistent_flags+=("--title=")
 619    flags+=("--no=")
 620    two_word_flags+=("--no")
 621    two_word_flags+=("-n")
 622    local_nonpersistent_flags+=("--no=")
 623    flags+=("--by=")
 624    two_word_flags+=("--by")
 625    two_word_flags+=("-b")
 626    local_nonpersistent_flags+=("--by=")
 627    flags+=("--direction=")
 628    two_word_flags+=("--direction")
 629    two_word_flags+=("-d")
 630    local_nonpersistent_flags+=("--direction=")
 631
 632    must_have_one_flag=()
 633    must_have_one_noun=()
 634    noun_aliases=()
 635}
 636
 637_git-bug_ls-id()
 638{
 639    last_command="git-bug_ls-id"
 640
 641    command_aliases=()
 642
 643    commands=()
 644
 645    flags=()
 646    two_word_flags=()
 647    local_nonpersistent_flags=()
 648    flags_with_completion=()
 649    flags_completion=()
 650
 651
 652    must_have_one_flag=()
 653    must_have_one_noun=()
 654    noun_aliases=()
 655}
 656
 657_git-bug_ls-label()
 658{
 659    last_command="git-bug_ls-label"
 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
 672    must_have_one_flag=()
 673    must_have_one_noun=()
 674    noun_aliases=()
 675}
 676
 677_git-bug_pull()
 678{
 679    last_command="git-bug_pull"
 680
 681    command_aliases=()
 682
 683    commands=()
 684
 685    flags=()
 686    two_word_flags=()
 687    local_nonpersistent_flags=()
 688    flags_with_completion=()
 689    flags_completion=()
 690
 691
 692    must_have_one_flag=()
 693    must_have_one_noun=()
 694    noun_aliases=()
 695}
 696
 697_git-bug_push()
 698{
 699    last_command="git-bug_push"
 700
 701    command_aliases=()
 702
 703    commands=()
 704
 705    flags=()
 706    two_word_flags=()
 707    local_nonpersistent_flags=()
 708    flags_with_completion=()
 709    flags_completion=()
 710
 711
 712    must_have_one_flag=()
 713    must_have_one_noun=()
 714    noun_aliases=()
 715}
 716
 717_git-bug_select()
 718{
 719    last_command="git-bug_select"
 720
 721    command_aliases=()
 722
 723    commands=()
 724
 725    flags=()
 726    two_word_flags=()
 727    local_nonpersistent_flags=()
 728    flags_with_completion=()
 729    flags_completion=()
 730
 731
 732    must_have_one_flag=()
 733    must_have_one_noun=()
 734    noun_aliases=()
 735}
 736
 737_git-bug_show()
 738{
 739    last_command="git-bug_show"
 740
 741    command_aliases=()
 742
 743    commands=()
 744
 745    flags=()
 746    two_word_flags=()
 747    local_nonpersistent_flags=()
 748    flags_with_completion=()
 749    flags_completion=()
 750
 751    flags+=("--field=")
 752    two_word_flags+=("--field")
 753    two_word_flags+=("-f")
 754    local_nonpersistent_flags+=("--field=")
 755
 756    must_have_one_flag=()
 757    must_have_one_noun=()
 758    noun_aliases=()
 759}
 760
 761_git-bug_status_close()
 762{
 763    last_command="git-bug_status_close"
 764
 765    command_aliases=()
 766
 767    commands=()
 768
 769    flags=()
 770    two_word_flags=()
 771    local_nonpersistent_flags=()
 772    flags_with_completion=()
 773    flags_completion=()
 774
 775
 776    must_have_one_flag=()
 777    must_have_one_noun=()
 778    noun_aliases=()
 779}
 780
 781_git-bug_status_open()
 782{
 783    last_command="git-bug_status_open"
 784
 785    command_aliases=()
 786
 787    commands=()
 788
 789    flags=()
 790    two_word_flags=()
 791    local_nonpersistent_flags=()
 792    flags_with_completion=()
 793    flags_completion=()
 794
 795
 796    must_have_one_flag=()
 797    must_have_one_noun=()
 798    noun_aliases=()
 799}
 800
 801_git-bug_status()
 802{
 803    last_command="git-bug_status"
 804
 805    command_aliases=()
 806
 807    commands=()
 808    commands+=("close")
 809    commands+=("open")
 810
 811    flags=()
 812    two_word_flags=()
 813    local_nonpersistent_flags=()
 814    flags_with_completion=()
 815    flags_completion=()
 816
 817
 818    must_have_one_flag=()
 819    must_have_one_noun=()
 820    noun_aliases=()
 821}
 822
 823_git-bug_termui()
 824{
 825    last_command="git-bug_termui"
 826
 827    command_aliases=()
 828
 829    commands=()
 830
 831    flags=()
 832    two_word_flags=()
 833    local_nonpersistent_flags=()
 834    flags_with_completion=()
 835    flags_completion=()
 836
 837
 838    must_have_one_flag=()
 839    must_have_one_noun=()
 840    noun_aliases=()
 841}
 842
 843_git-bug_title_edit()
 844{
 845    last_command="git-bug_title_edit"
 846
 847    command_aliases=()
 848
 849    commands=()
 850
 851    flags=()
 852    two_word_flags=()
 853    local_nonpersistent_flags=()
 854    flags_with_completion=()
 855    flags_completion=()
 856
 857    flags+=("--title=")
 858    two_word_flags+=("--title")
 859    two_word_flags+=("-t")
 860    local_nonpersistent_flags+=("--title=")
 861
 862    must_have_one_flag=()
 863    must_have_one_noun=()
 864    noun_aliases=()
 865}
 866
 867_git-bug_title()
 868{
 869    last_command="git-bug_title"
 870
 871    command_aliases=()
 872
 873    commands=()
 874    commands+=("edit")
 875
 876    flags=()
 877    two_word_flags=()
 878    local_nonpersistent_flags=()
 879    flags_with_completion=()
 880    flags_completion=()
 881
 882
 883    must_have_one_flag=()
 884    must_have_one_noun=()
 885    noun_aliases=()
 886}
 887
 888_git-bug_user_adopt()
 889{
 890    last_command="git-bug_user_adopt"
 891
 892    command_aliases=()
 893
 894    commands=()
 895
 896    flags=()
 897    two_word_flags=()
 898    local_nonpersistent_flags=()
 899    flags_with_completion=()
 900    flags_completion=()
 901
 902
 903    must_have_one_flag=()
 904    must_have_one_noun=()
 905    noun_aliases=()
 906}
 907
 908_git-bug_user_create()
 909{
 910    last_command="git-bug_user_create"
 911
 912    command_aliases=()
 913
 914    commands=()
 915
 916    flags=()
 917    two_word_flags=()
 918    local_nonpersistent_flags=()
 919    flags_with_completion=()
 920    flags_completion=()
 921
 922
 923    must_have_one_flag=()
 924    must_have_one_noun=()
 925    noun_aliases=()
 926}
 927
 928_git-bug_user_ls()
 929{
 930    last_command="git-bug_user_ls"
 931
 932    command_aliases=()
 933
 934    commands=()
 935
 936    flags=()
 937    two_word_flags=()
 938    local_nonpersistent_flags=()
 939    flags_with_completion=()
 940    flags_completion=()
 941
 942
 943    must_have_one_flag=()
 944    must_have_one_noun=()
 945    noun_aliases=()
 946}
 947
 948_git-bug_user()
 949{
 950    last_command="git-bug_user"
 951
 952    command_aliases=()
 953
 954    commands=()
 955    commands+=("adopt")
 956    commands+=("create")
 957    commands+=("ls")
 958
 959    flags=()
 960    two_word_flags=()
 961    local_nonpersistent_flags=()
 962    flags_with_completion=()
 963    flags_completion=()
 964
 965    flags+=("--field=")
 966    two_word_flags+=("--field")
 967    two_word_flags+=("-f")
 968    local_nonpersistent_flags+=("--field=")
 969
 970    must_have_one_flag=()
 971    must_have_one_noun=()
 972    noun_aliases=()
 973}
 974
 975_git-bug_version()
 976{
 977    last_command="git-bug_version"
 978
 979    command_aliases=()
 980
 981    commands=()
 982
 983    flags=()
 984    two_word_flags=()
 985    local_nonpersistent_flags=()
 986    flags_with_completion=()
 987    flags_completion=()
 988
 989    flags+=("--number")
 990    flags+=("-n")
 991    local_nonpersistent_flags+=("--number")
 992    flags+=("--commit")
 993    flags+=("-c")
 994    local_nonpersistent_flags+=("--commit")
 995    flags+=("--all")
 996    flags+=("-a")
 997    local_nonpersistent_flags+=("--all")
 998
 999    must_have_one_flag=()
1000    must_have_one_noun=()
1001    noun_aliases=()
1002}
1003
1004_git-bug_webui()
1005{
1006    last_command="git-bug_webui"
1007
1008    command_aliases=()
1009
1010    commands=()
1011
1012    flags=()
1013    two_word_flags=()
1014    local_nonpersistent_flags=()
1015    flags_with_completion=()
1016    flags_completion=()
1017
1018    flags+=("--open")
1019    local_nonpersistent_flags+=("--open")
1020    flags+=("--no-open")
1021    local_nonpersistent_flags+=("--no-open")
1022    flags+=("--port=")
1023    two_word_flags+=("--port")
1024    two_word_flags+=("-p")
1025    local_nonpersistent_flags+=("--port=")
1026
1027    must_have_one_flag=()
1028    must_have_one_noun=()
1029    noun_aliases=()
1030}
1031
1032_git-bug_root_command()
1033{
1034    last_command="git-bug"
1035
1036    command_aliases=()
1037
1038    commands=()
1039    commands+=("add")
1040    commands+=("bridge")
1041    commands+=("commands")
1042    commands+=("comment")
1043    commands+=("deselect")
1044    commands+=("label")
1045    commands+=("ls")
1046    commands+=("ls-id")
1047    commands+=("ls-label")
1048    commands+=("pull")
1049    commands+=("push")
1050    commands+=("select")
1051    commands+=("show")
1052    commands+=("status")
1053    commands+=("termui")
1054    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
1055        command_aliases+=("tui")
1056        aliashash["tui"]="termui"
1057    fi
1058    commands+=("title")
1059    commands+=("user")
1060    commands+=("version")
1061    commands+=("webui")
1062
1063    flags=()
1064    two_word_flags=()
1065    local_nonpersistent_flags=()
1066    flags_with_completion=()
1067    flags_completion=()
1068
1069
1070    must_have_one_flag=()
1071    must_have_one_noun=()
1072    noun_aliases=()
1073}
1074
1075__start_git-bug()
1076{
1077    local cur prev words cword
1078    declare -A flaghash 2>/dev/null || :
1079    declare -A aliashash 2>/dev/null || :
1080    if declare -F _init_completion >/dev/null 2>&1; then
1081        _init_completion -s || return
1082    else
1083        __git-bug_init_completion -n "=" || return
1084    fi
1085
1086    local c=0
1087    local flags=()
1088    local two_word_flags=()
1089    local local_nonpersistent_flags=()
1090    local flags_with_completion=()
1091    local flags_completion=()
1092    local commands=("git-bug")
1093    local must_have_one_flag=()
1094    local must_have_one_noun=()
1095    local last_command
1096    local nouns=()
1097
1098    __git-bug_handle_word
1099}
1100
1101if [[ $(type -t compopt) = "builtin" ]]; then
1102    complete -o default -F __start_git-bug git-bug
1103else
1104    complete -o default -o nospace -F __start_git-bug git-bug
1105fi
1106
1107# ex: ts=4 sw=4 et filetype=sh