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