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+=("--project=")
 325    two_word_flags+=("--project")
 326    two_word_flags+=("-p")
 327    local_nonpersistent_flags+=("--project=")
 328
 329    must_have_one_flag=()
 330    must_have_one_noun=()
 331    noun_aliases=()
 332}
 333
 334_git-bug_bridge_pull()
 335{
 336    last_command="git-bug_bridge_pull"
 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_rm()
 355{
 356    last_command="git-bug_bridge_rm"
 357
 358    command_aliases=()
 359
 360    commands=()
 361
 362    flags=()
 363    two_word_flags=()
 364    local_nonpersistent_flags=()
 365    flags_with_completion=()
 366    flags_completion=()
 367
 368
 369    must_have_one_flag=()
 370    must_have_one_noun=()
 371    noun_aliases=()
 372}
 373
 374_git-bug_bridge()
 375{
 376    last_command="git-bug_bridge"
 377
 378    command_aliases=()
 379
 380    commands=()
 381    commands+=("configure")
 382    commands+=("pull")
 383    commands+=("rm")
 384
 385    flags=()
 386    two_word_flags=()
 387    local_nonpersistent_flags=()
 388    flags_with_completion=()
 389    flags_completion=()
 390
 391
 392    must_have_one_flag=()
 393    must_have_one_noun=()
 394    noun_aliases=()
 395}
 396
 397_git-bug_commands()
 398{
 399    last_command="git-bug_commands"
 400
 401    command_aliases=()
 402
 403    commands=()
 404
 405    flags=()
 406    two_word_flags=()
 407    local_nonpersistent_flags=()
 408    flags_with_completion=()
 409    flags_completion=()
 410
 411    flags+=("--pretty")
 412    flags+=("-p")
 413    local_nonpersistent_flags+=("--pretty")
 414
 415    must_have_one_flag=()
 416    must_have_one_noun=()
 417    noun_aliases=()
 418}
 419
 420_git-bug_comment_add()
 421{
 422    last_command="git-bug_comment_add"
 423
 424    command_aliases=()
 425
 426    commands=()
 427
 428    flags=()
 429    two_word_flags=()
 430    local_nonpersistent_flags=()
 431    flags_with_completion=()
 432    flags_completion=()
 433
 434    flags+=("--file=")
 435    two_word_flags+=("--file")
 436    two_word_flags+=("-F")
 437    local_nonpersistent_flags+=("--file=")
 438    flags+=("--message=")
 439    two_word_flags+=("--message")
 440    two_word_flags+=("-m")
 441    local_nonpersistent_flags+=("--message=")
 442
 443    must_have_one_flag=()
 444    must_have_one_noun=()
 445    noun_aliases=()
 446}
 447
 448_git-bug_comment()
 449{
 450    last_command="git-bug_comment"
 451
 452    command_aliases=()
 453
 454    commands=()
 455    commands+=("add")
 456
 457    flags=()
 458    two_word_flags=()
 459    local_nonpersistent_flags=()
 460    flags_with_completion=()
 461    flags_completion=()
 462
 463
 464    must_have_one_flag=()
 465    must_have_one_noun=()
 466    noun_aliases=()
 467}
 468
 469_git-bug_deselect()
 470{
 471    last_command="git-bug_deselect"
 472
 473    command_aliases=()
 474
 475    commands=()
 476
 477    flags=()
 478    two_word_flags=()
 479    local_nonpersistent_flags=()
 480    flags_with_completion=()
 481    flags_completion=()
 482
 483
 484    must_have_one_flag=()
 485    must_have_one_noun=()
 486    noun_aliases=()
 487}
 488
 489_git-bug_label_add()
 490{
 491    last_command="git-bug_label_add"
 492
 493    command_aliases=()
 494
 495    commands=()
 496
 497    flags=()
 498    two_word_flags=()
 499    local_nonpersistent_flags=()
 500    flags_with_completion=()
 501    flags_completion=()
 502
 503
 504    must_have_one_flag=()
 505    must_have_one_noun=()
 506    noun_aliases=()
 507}
 508
 509_git-bug_label_rm()
 510{
 511    last_command="git-bug_label_rm"
 512
 513    command_aliases=()
 514
 515    commands=()
 516
 517    flags=()
 518    two_word_flags=()
 519    local_nonpersistent_flags=()
 520    flags_with_completion=()
 521    flags_completion=()
 522
 523
 524    must_have_one_flag=()
 525    must_have_one_noun=()
 526    noun_aliases=()
 527}
 528
 529_git-bug_label()
 530{
 531    last_command="git-bug_label"
 532
 533    command_aliases=()
 534
 535    commands=()
 536    commands+=("add")
 537    commands+=("rm")
 538
 539    flags=()
 540    two_word_flags=()
 541    local_nonpersistent_flags=()
 542    flags_with_completion=()
 543    flags_completion=()
 544
 545
 546    must_have_one_flag=()
 547    must_have_one_noun=()
 548    noun_aliases=()
 549}
 550
 551_git-bug_ls()
 552{
 553    last_command="git-bug_ls"
 554
 555    command_aliases=()
 556
 557    commands=()
 558
 559    flags=()
 560    two_word_flags=()
 561    local_nonpersistent_flags=()
 562    flags_with_completion=()
 563    flags_completion=()
 564
 565    flags+=("--status=")
 566    two_word_flags+=("--status")
 567    two_word_flags+=("-s")
 568    local_nonpersistent_flags+=("--status=")
 569    flags+=("--author=")
 570    two_word_flags+=("--author")
 571    two_word_flags+=("-a")
 572    local_nonpersistent_flags+=("--author=")
 573    flags+=("--participant=")
 574    two_word_flags+=("--participant")
 575    two_word_flags+=("-p")
 576    local_nonpersistent_flags+=("--participant=")
 577    flags+=("--actor=")
 578    two_word_flags+=("--actor")
 579    two_word_flags+=("-A")
 580    local_nonpersistent_flags+=("--actor=")
 581    flags+=("--label=")
 582    two_word_flags+=("--label")
 583    two_word_flags+=("-l")
 584    local_nonpersistent_flags+=("--label=")
 585    flags+=("--title=")
 586    two_word_flags+=("--title")
 587    two_word_flags+=("-t")
 588    local_nonpersistent_flags+=("--title=")
 589    flags+=("--no=")
 590    two_word_flags+=("--no")
 591    two_word_flags+=("-n")
 592    local_nonpersistent_flags+=("--no=")
 593    flags+=("--by=")
 594    two_word_flags+=("--by")
 595    two_word_flags+=("-b")
 596    local_nonpersistent_flags+=("--by=")
 597    flags+=("--direction=")
 598    two_word_flags+=("--direction")
 599    two_word_flags+=("-d")
 600    local_nonpersistent_flags+=("--direction=")
 601
 602    must_have_one_flag=()
 603    must_have_one_noun=()
 604    noun_aliases=()
 605}
 606
 607_git-bug_ls-id()
 608{
 609    last_command="git-bug_ls-id"
 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_ls-label()
 628{
 629    last_command="git-bug_ls-label"
 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_pull()
 648{
 649    last_command="git-bug_pull"
 650
 651    command_aliases=()
 652
 653    commands=()
 654
 655    flags=()
 656    two_word_flags=()
 657    local_nonpersistent_flags=()
 658    flags_with_completion=()
 659    flags_completion=()
 660
 661
 662    must_have_one_flag=()
 663    must_have_one_noun=()
 664    noun_aliases=()
 665}
 666
 667_git-bug_push()
 668{
 669    last_command="git-bug_push"
 670
 671    command_aliases=()
 672
 673    commands=()
 674
 675    flags=()
 676    two_word_flags=()
 677    local_nonpersistent_flags=()
 678    flags_with_completion=()
 679    flags_completion=()
 680
 681
 682    must_have_one_flag=()
 683    must_have_one_noun=()
 684    noun_aliases=()
 685}
 686
 687_git-bug_select()
 688{
 689    last_command="git-bug_select"
 690
 691    command_aliases=()
 692
 693    commands=()
 694
 695    flags=()
 696    two_word_flags=()
 697    local_nonpersistent_flags=()
 698    flags_with_completion=()
 699    flags_completion=()
 700
 701
 702    must_have_one_flag=()
 703    must_have_one_noun=()
 704    noun_aliases=()
 705}
 706
 707_git-bug_show()
 708{
 709    last_command="git-bug_show"
 710
 711    command_aliases=()
 712
 713    commands=()
 714
 715    flags=()
 716    two_word_flags=()
 717    local_nonpersistent_flags=()
 718    flags_with_completion=()
 719    flags_completion=()
 720
 721    flags+=("--field=")
 722    two_word_flags+=("--field")
 723    two_word_flags+=("-f")
 724    local_nonpersistent_flags+=("--field=")
 725
 726    must_have_one_flag=()
 727    must_have_one_noun=()
 728    noun_aliases=()
 729}
 730
 731_git-bug_status_close()
 732{
 733    last_command="git-bug_status_close"
 734
 735    command_aliases=()
 736
 737    commands=()
 738
 739    flags=()
 740    two_word_flags=()
 741    local_nonpersistent_flags=()
 742    flags_with_completion=()
 743    flags_completion=()
 744
 745
 746    must_have_one_flag=()
 747    must_have_one_noun=()
 748    noun_aliases=()
 749}
 750
 751_git-bug_status_open()
 752{
 753    last_command="git-bug_status_open"
 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_status()
 772{
 773    last_command="git-bug_status"
 774
 775    command_aliases=()
 776
 777    commands=()
 778    commands+=("close")
 779    commands+=("open")
 780
 781    flags=()
 782    two_word_flags=()
 783    local_nonpersistent_flags=()
 784    flags_with_completion=()
 785    flags_completion=()
 786
 787
 788    must_have_one_flag=()
 789    must_have_one_noun=()
 790    noun_aliases=()
 791}
 792
 793_git-bug_termui()
 794{
 795    last_command="git-bug_termui"
 796
 797    command_aliases=()
 798
 799    commands=()
 800
 801    flags=()
 802    two_word_flags=()
 803    local_nonpersistent_flags=()
 804    flags_with_completion=()
 805    flags_completion=()
 806
 807
 808    must_have_one_flag=()
 809    must_have_one_noun=()
 810    noun_aliases=()
 811}
 812
 813_git-bug_title_edit()
 814{
 815    last_command="git-bug_title_edit"
 816
 817    command_aliases=()
 818
 819    commands=()
 820
 821    flags=()
 822    two_word_flags=()
 823    local_nonpersistent_flags=()
 824    flags_with_completion=()
 825    flags_completion=()
 826
 827    flags+=("--title=")
 828    two_word_flags+=("--title")
 829    two_word_flags+=("-t")
 830    local_nonpersistent_flags+=("--title=")
 831
 832    must_have_one_flag=()
 833    must_have_one_noun=()
 834    noun_aliases=()
 835}
 836
 837_git-bug_title()
 838{
 839    last_command="git-bug_title"
 840
 841    command_aliases=()
 842
 843    commands=()
 844    commands+=("edit")
 845
 846    flags=()
 847    two_word_flags=()
 848    local_nonpersistent_flags=()
 849    flags_with_completion=()
 850    flags_completion=()
 851
 852
 853    must_have_one_flag=()
 854    must_have_one_noun=()
 855    noun_aliases=()
 856}
 857
 858_git-bug_user_adopt()
 859{
 860    last_command="git-bug_user_adopt"
 861
 862    command_aliases=()
 863
 864    commands=()
 865
 866    flags=()
 867    two_word_flags=()
 868    local_nonpersistent_flags=()
 869    flags_with_completion=()
 870    flags_completion=()
 871
 872
 873    must_have_one_flag=()
 874    must_have_one_noun=()
 875    noun_aliases=()
 876}
 877
 878_git-bug_user_create()
 879{
 880    last_command="git-bug_user_create"
 881
 882    command_aliases=()
 883
 884    commands=()
 885
 886    flags=()
 887    two_word_flags=()
 888    local_nonpersistent_flags=()
 889    flags_with_completion=()
 890    flags_completion=()
 891
 892
 893    must_have_one_flag=()
 894    must_have_one_noun=()
 895    noun_aliases=()
 896}
 897
 898_git-bug_user_ls()
 899{
 900    last_command="git-bug_user_ls"
 901
 902    command_aliases=()
 903
 904    commands=()
 905
 906    flags=()
 907    two_word_flags=()
 908    local_nonpersistent_flags=()
 909    flags_with_completion=()
 910    flags_completion=()
 911
 912
 913    must_have_one_flag=()
 914    must_have_one_noun=()
 915    noun_aliases=()
 916}
 917
 918_git-bug_user()
 919{
 920    last_command="git-bug_user"
 921
 922    command_aliases=()
 923
 924    commands=()
 925    commands+=("adopt")
 926    commands+=("create")
 927    commands+=("ls")
 928
 929    flags=()
 930    two_word_flags=()
 931    local_nonpersistent_flags=()
 932    flags_with_completion=()
 933    flags_completion=()
 934
 935    flags+=("--field=")
 936    two_word_flags+=("--field")
 937    two_word_flags+=("-f")
 938    local_nonpersistent_flags+=("--field=")
 939
 940    must_have_one_flag=()
 941    must_have_one_noun=()
 942    noun_aliases=()
 943}
 944
 945_git-bug_version()
 946{
 947    last_command="git-bug_version"
 948
 949    command_aliases=()
 950
 951    commands=()
 952
 953    flags=()
 954    two_word_flags=()
 955    local_nonpersistent_flags=()
 956    flags_with_completion=()
 957    flags_completion=()
 958
 959    flags+=("--number")
 960    flags+=("-n")
 961    local_nonpersistent_flags+=("--number")
 962    flags+=("--commit")
 963    flags+=("-c")
 964    local_nonpersistent_flags+=("--commit")
 965    flags+=("--all")
 966    flags+=("-a")
 967    local_nonpersistent_flags+=("--all")
 968
 969    must_have_one_flag=()
 970    must_have_one_noun=()
 971    noun_aliases=()
 972}
 973
 974_git-bug_webui()
 975{
 976    last_command="git-bug_webui"
 977
 978    command_aliases=()
 979
 980    commands=()
 981
 982    flags=()
 983    two_word_flags=()
 984    local_nonpersistent_flags=()
 985    flags_with_completion=()
 986    flags_completion=()
 987
 988    flags+=("--open")
 989    local_nonpersistent_flags+=("--open")
 990    flags+=("--no-open")
 991    local_nonpersistent_flags+=("--no-open")
 992    flags+=("--port=")
 993    two_word_flags+=("--port")
 994    two_word_flags+=("-p")
 995    local_nonpersistent_flags+=("--port=")
 996
 997    must_have_one_flag=()
 998    must_have_one_noun=()
 999    noun_aliases=()
1000}
1001
1002_git-bug_root_command()
1003{
1004    last_command="git-bug"
1005
1006    command_aliases=()
1007
1008    commands=()
1009    commands+=("add")
1010    commands+=("bridge")
1011    commands+=("commands")
1012    commands+=("comment")
1013    commands+=("deselect")
1014    commands+=("label")
1015    commands+=("ls")
1016    commands+=("ls-id")
1017    commands+=("ls-label")
1018    commands+=("pull")
1019    commands+=("push")
1020    commands+=("select")
1021    commands+=("show")
1022    commands+=("status")
1023    commands+=("termui")
1024    commands+=("title")
1025    commands+=("user")
1026    commands+=("version")
1027    commands+=("webui")
1028
1029    flags=()
1030    two_word_flags=()
1031    local_nonpersistent_flags=()
1032    flags_with_completion=()
1033    flags_completion=()
1034
1035
1036    must_have_one_flag=()
1037    must_have_one_noun=()
1038    noun_aliases=()
1039}
1040
1041__start_git-bug()
1042{
1043    local cur prev words cword
1044    declare -A flaghash 2>/dev/null || :
1045    declare -A aliashash 2>/dev/null || :
1046    if declare -F _init_completion >/dev/null 2>&1; then
1047        _init_completion -s || return
1048    else
1049        __git-bug_init_completion -n "=" || return
1050    fi
1051
1052    local c=0
1053    local flags=()
1054    local two_word_flags=()
1055    local local_nonpersistent_flags=()
1056    local flags_with_completion=()
1057    local flags_completion=()
1058    local commands=("git-bug")
1059    local must_have_one_flag=()
1060    local must_have_one_noun=()
1061    local last_command
1062    local nouns=()
1063
1064    __git-bug_handle_word
1065}
1066
1067if [[ $(type -t compopt) = "builtin" ]]; then
1068    complete -o default -F __start_git-bug git-bug
1069else
1070    complete -o default -o nospace -F __start_git-bug git-bug
1071fi
1072
1073# ex: ts=4 sw=4 et filetype=sh