A new user interface for you! Read more...

File l3t-autocomplete.sh of Package golang-l3t

# bash completion for l3t                                  -*- shell-script -*-

__l3t_debug()
{
    if [[ -n ${BASH_COMP_DEBUG_FILE} ]]; then
        echo "$*" >> "${BASH_COMP_DEBUG_FILE}"
    fi
}

# Homebrew on Macs have version 1.3 of bash-completion which doesn't include
# _init_completion. This is a very minimal version of that function.
__l3t_init_completion()
{
    COMPREPLY=()
    _get_comp_words_by_ref "$@" cur prev words cword
}

__l3t_index_of_word()
{
    local w word=$1
    shift
    index=0
    for w in "$@"; do
        [[ $w = "$word" ]] && return
        index=$((index+1))
    done
    index=-1
}

__l3t_contains_word()
{
    local w word=$1; shift
    for w in "$@"; do
        [[ $w = "$word" ]] && return
    done
    return 1
}

__l3t_handle_reply()
{
    __l3t_debug "${FUNCNAME[0]}"
    case $cur in
        -*)
            if [[ $(type -t compopt) = "builtin" ]]; then
                compopt -o nospace
            fi
            local allflags
            if [ ${#must_have_one_flag[@]} -ne 0 ]; then
                allflags=("${must_have_one_flag[@]}")
            else
                allflags=("${flags[*]} ${two_word_flags[*]}")
            fi
            COMPREPLY=( $(compgen -W "${allflags[*]}" -- "$cur") )
            if [[ $(type -t compopt) = "builtin" ]]; then
                [[ "${COMPREPLY[0]}" == *= ]] || compopt +o nospace
            fi

            # complete after --flag=abc
            if [[ $cur == *=* ]]; then
                if [[ $(type -t compopt) = "builtin" ]]; then
                    compopt +o nospace
                fi

                local index flag
                flag="${cur%=*}"
                __l3t_index_of_word "${flag}" "${flags_with_completion[@]}"
                COMPREPLY=()
                if [[ ${index} -ge 0 ]]; then
                    PREFIX=""
                    cur="${cur#*=}"
                    ${flags_completion[${index}]}
                    if [ -n "${ZSH_VERSION}" ]; then
                        # zsh completion needs --flag= prefix
                        eval "COMPREPLY=( \"\${COMPREPLY[@]/#/${flag}=}\" )"
                    fi
                fi
            fi
            return 0;
            ;;
    esac

    # check if we are handling a flag with special work handling
    local index
    __l3t_index_of_word "${prev}" "${flags_with_completion[@]}"
    if [[ ${index} -ge 0 ]]; then
        ${flags_completion[${index}]}
        return
    fi

    # we are parsing a flag and don't have a special handler, no completion
    if [[ ${cur} != "${words[cword]}" ]]; then
        return
    fi

    local completions
    completions=("${commands[@]}")
    if [[ ${#must_have_one_noun[@]} -ne 0 ]]; then
        completions=("${must_have_one_noun[@]}")
    fi
    if [[ ${#must_have_one_flag[@]} -ne 0 ]]; then
        completions+=("${must_have_one_flag[@]}")
    fi
    COMPREPLY=( $(compgen -W "${completions[*]}" -- "$cur") )

    if [[ ${#COMPREPLY[@]} -eq 0 && ${#noun_aliases[@]} -gt 0 && ${#must_have_one_noun[@]} -ne 0 ]]; then
        COMPREPLY=( $(compgen -W "${noun_aliases[*]}" -- "$cur") )
    fi

    if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
        declare -F __custom_func >/dev/null && __custom_func
    fi

    # available in bash-completion >= 2, not always present on macOS
    if declare -F __ltrim_colon_completions >/dev/null; then
        __ltrim_colon_completions "$cur"
    fi

    # If there is only 1 completion and it is a flag with an = it will be completed
    # but we don't want a space after the =
    if [[ "${#COMPREPLY[@]}" -eq "1" ]] && [[ $(type -t compopt) = "builtin" ]] && [[ "${COMPREPLY[0]}" == --*= ]]; then
       compopt -o nospace
    fi
}

# The arguments should be in the form "ext1|ext2|extn"
__l3t_handle_filename_extension_flag()
{
    local ext="$1"
    _filedir "@(${ext})"
}

__l3t_handle_subdirs_in_dir_flag()
{
    local dir="$1"
    pushd "${dir}" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1
}

__l3t_handle_flag()
{
    __l3t_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"

    # if a command required a flag, and we found it, unset must_have_one_flag()
    local flagname=${words[c]}
    local flagvalue
    # if the word contained an =
    if [[ ${words[c]} == *"="* ]]; then
        flagvalue=${flagname#*=} # take in as flagvalue after the =
        flagname=${flagname%=*} # strip everything after the =
        flagname="${flagname}=" # but put the = back
    fi
    __l3t_debug "${FUNCNAME[0]}: looking for ${flagname}"
    if __l3t_contains_word "${flagname}" "${must_have_one_flag[@]}"; then
        must_have_one_flag=()
    fi

    # if you set a flag which only applies to this command, don't show subcommands
    if __l3t_contains_word "${flagname}" "${local_nonpersistent_flags[@]}"; then
      commands=()
    fi

    # keep flag value with flagname as flaghash
    # flaghash variable is an associative array which is only supported in bash > 3.
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        if [ -n "${flagvalue}" ] ; then
            flaghash[${flagname}]=${flagvalue}
        elif [ -n "${words[ $((c+1)) ]}" ] ; then
            flaghash[${flagname}]=${words[ $((c+1)) ]}
        else
            flaghash[${flagname}]="true" # pad "true" for bool flag
        fi
    fi

    # skip the argument to a two word flag
    if __l3t_contains_word "${words[c]}" "${two_word_flags[@]}"; then
        c=$((c+1))
        # if we are looking for a flags value, don't show commands
        if [[ $c -eq $cword ]]; then
            commands=()
        fi
    fi

    c=$((c+1))

}

__l3t_handle_noun()
{
    __l3t_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"

    if __l3t_contains_word "${words[c]}" "${must_have_one_noun[@]}"; then
        must_have_one_noun=()
    elif __l3t_contains_word "${words[c]}" "${noun_aliases[@]}"; then
        must_have_one_noun=()
    fi

    nouns+=("${words[c]}")
    c=$((c+1))
}

__l3t_handle_command()
{
    __l3t_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"

    local next_command
    if [[ -n ${last_command} ]]; then
        next_command="_${last_command}_${words[c]//:/__}"
    else
        if [[ $c -eq 0 ]]; then
            next_command="_l3t_root_command"
        else
            next_command="_${words[c]//:/__}"
        fi
    fi
    c=$((c+1))
    __l3t_debug "${FUNCNAME[0]}: looking for ${next_command}"
    declare -F "$next_command" >/dev/null && $next_command
}

__l3t_handle_word()
{
    if [[ $c -ge $cword ]]; then
        __l3t_handle_reply
        return
    fi
    __l3t_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
    if [[ "${words[c]}" == -* ]]; then
        __l3t_handle_flag
    elif __l3t_contains_word "${words[c]}" "${commands[@]}"; then
        __l3t_handle_command
    elif [[ $c -eq 0 ]]; then
        __l3t_handle_command
    elif __l3t_contains_word "${words[c]}" "${command_aliases[@]}"; then
        # aliashash variable is an associative array which is only supported in bash > 3.
        if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
            words[c]=${aliashash[${words[c]}]}
            __l3t_handle_command
        else
            __l3t_handle_noun
        fi
    else
        __l3t_handle_noun
    fi
    __l3t_handle_word
}

_l3t_accept()
{
    last_command="l3t_accept"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--bug=")
    two_word_flags+=("-b")
    local_nonpersistent_flags+=("--bug=")
    flags+=("--config=")
    local_nonpersistent_flags+=("--config=")
    flags+=("--incident=")
    two_word_flags+=("-i")
    local_nonpersistent_flags+=("--incident=")
    flags+=("--set=")
    local_nonpersistent_flags+=("--set=")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_assign()
{
    last_command="l3t_assign"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--bug=")
    two_word_flags+=("-b")
    local_nonpersistent_flags+=("--bug=")
    flags+=("--config=")
    local_nonpersistent_flags+=("--config=")
    flags+=("--incident=")
    two_word_flags+=("-i")
    local_nonpersistent_flags+=("--incident=")
    flags+=("--set=")
    local_nonpersistent_flags+=("--set=")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_config()
{
    last_command="l3t_config"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--config=")
    local_nonpersistent_flags+=("--config=")
    flags+=("--defaults")
    flags+=("-d")
    local_nonpersistent_flags+=("--defaults")
    flags+=("--set=")
    local_nonpersistent_flags+=("--set=")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_create-ptf()
{
    last_command="l3t_create-ptf"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--arch=")
    two_word_flags+=("-a")
    local_nonpersistent_flags+=("--arch=")
    flags+=("--bug=")
    two_word_flags+=("-b")
    local_nonpersistent_flags+=("--bug=")
    flags+=("--config=")
    local_nonpersistent_flags+=("--config=")
    flags+=("--incident=")
    two_word_flags+=("-i")
    local_nonpersistent_flags+=("--incident=")
    flags+=("--product=")
    two_word_flags+=("-p")
    local_nonpersistent_flags+=("--product=")
    flags+=("--set=")
    local_nonpersistent_flags+=("--set=")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_edit-bug()
{
    last_command="l3t_edit-bug"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--assignee=")
    two_word_flags+=("-a")
    local_nonpersistent_flags+=("--assignee=")
    flags+=("--bug=")
    two_word_flags+=("-b")
    local_nonpersistent_flags+=("--bug=")
    flags+=("--cc=")
    two_word_flags+=("-C")
    local_nonpersistent_flags+=("--cc=")
    flags+=("--ccme")
    flags+=("-M")
    local_nonpersistent_flags+=("--ccme")
    flags+=("--clear-needinfo")
    flags+=("-N")
    local_nonpersistent_flags+=("--clear-needinfo")
    flags+=("--comment")
    flags+=("-c")
    local_nonpersistent_flags+=("--comment")
    flags+=("--config=")
    local_nonpersistent_flags+=("--config=")
    flags+=("--description=")
    two_word_flags+=("-d")
    local_nonpersistent_flags+=("--description=")
    flags+=("--duplicate=")
    local_nonpersistent_flags+=("--duplicate=")
    flags+=("--incident=")
    two_word_flags+=("-i")
    local_nonpersistent_flags+=("--incident=")
    flags+=("--message=")
    two_word_flags+=("-m")
    local_nonpersistent_flags+=("--message=")
    flags+=("--needinfo=")
    two_word_flags+=("-n")
    local_nonpersistent_flags+=("--needinfo=")
    flags+=("--non-private-is-ok")
    flags+=("-P")
    local_nonpersistent_flags+=("--non-private-is-ok")
    flags+=("--priority=")
    local_nonpersistent_flags+=("--priority=")
    flags+=("--private")
    flags+=("-p")
    local_nonpersistent_flags+=("--private")
    flags+=("--remove-cc=")
    two_word_flags+=("-R")
    local_nonpersistent_flags+=("--remove-cc=")
    flags+=("--remove-needinfo=")
    two_word_flags+=("-I")
    local_nonpersistent_flags+=("--remove-needinfo=")
    flags+=("--resolution=")
    two_word_flags+=("-r")
    local_nonpersistent_flags+=("--resolution=")
    flags+=("--set=")
    local_nonpersistent_flags+=("--set=")
    flags+=("--status=")
    two_word_flags+=("-s")
    local_nonpersistent_flags+=("--status=")
    flags+=("--url=")
    two_word_flags+=("-u")
    local_nonpersistent_flags+=("--url=")
    flags+=("--whiteboard=")
    two_word_flags+=("-w")
    local_nonpersistent_flags+=("--whiteboard=")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_expand-bug()
{
    last_command="l3t_expand-bug"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--bug=")
    two_word_flags+=("-b")
    local_nonpersistent_flags+=("--bug=")
    flags+=("--config=")
    local_nonpersistent_flags+=("--config=")
    flags+=("--incident=")
    two_word_flags+=("-i")
    local_nonpersistent_flags+=("--incident=")
    flags+=("--set=")
    local_nonpersistent_flags+=("--set=")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_expand-incident()
{
    last_command="l3t_expand-incident"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--bug=")
    two_word_flags+=("-b")
    local_nonpersistent_flags+=("--bug=")
    flags+=("--config=")
    local_nonpersistent_flags+=("--config=")
    flags+=("--incident=")
    two_word_flags+=("-i")
    local_nonpersistent_flags+=("--incident=")
    flags+=("--set=")
    local_nonpersistent_flags+=("--set=")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_get-attachment()
{
    last_command="l3t_get-attachment"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--attachment=")
    two_word_flags+=("-a")
    local_nonpersistent_flags+=("--attachment=")
    flags+=("--bug=")
    two_word_flags+=("-b")
    local_nonpersistent_flags+=("--bug=")
    flags+=("--config=")
    local_nonpersistent_flags+=("--config=")
    flags+=("--dest=")
    two_word_flags+=("-d")
    local_nonpersistent_flags+=("--dest=")
    flags+=("--force")
    flags+=("-f")
    local_nonpersistent_flags+=("--force")
    flags+=("--incident=")
    two_word_flags+=("-i")
    local_nonpersistent_flags+=("--incident=")
    flags+=("--output=")
    two_word_flags+=("-o")
    local_nonpersistent_flags+=("--output=")
    flags+=("--set=")
    local_nonpersistent_flags+=("--set=")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_get-bug()
{
    last_command="l3t_get-bug"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--bug=")
    two_word_flags+=("-b")
    local_nonpersistent_flags+=("--bug=")
    flags+=("--config=")
    local_nonpersistent_flags+=("--config=")
    flags+=("--incident=")
    two_word_flags+=("-i")
    local_nonpersistent_flags+=("--incident=")
    flags+=("--last-comments=")
    two_word_flags+=("-n")
    local_nonpersistent_flags+=("--last-comments=")
    flags+=("--set=")
    local_nonpersistent_flags+=("--set=")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_get-incident()
{
    last_command="l3t_get-incident"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--bug=")
    two_word_flags+=("-b")
    local_nonpersistent_flags+=("--bug=")
    flags+=("--config=")
    local_nonpersistent_flags+=("--config=")
    flags+=("--incident=")
    two_word_flags+=("-i")
    local_nonpersistent_flags+=("--incident=")
    flags+=("--set=")
    local_nonpersistent_flags+=("--set=")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_get-sg-bug()
{
    last_command="l3t_get-sg-bug"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--bug=")
    two_word_flags+=("-b")
    local_nonpersistent_flags+=("--bug=")
    flags+=("--incident=")
    two_word_flags+=("-i")
    local_nonpersistent_flags+=("--incident=")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_ls()
{
    last_command="l3t_ls"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--active")
    flags+=("-a")
    local_nonpersistent_flags+=("--active")
    flags+=("--backup")
    flags+=("-b")
    local_nonpersistent_flags+=("--backup")
    flags+=("--closed")
    flags+=("-c")
    local_nonpersistent_flags+=("--closed")
    flags+=("--config=")
    local_nonpersistent_flags+=("--config=")
    flags+=("--mine")
    flags+=("-m")
    local_nonpersistent_flags+=("--mine")
    flags+=("--new")
    flags+=("-n")
    local_nonpersistent_flags+=("--new")
    flags+=("--no-headers")
    flags+=("-H")
    local_nonpersistent_flags+=("--no-headers")
    flags+=("--processed")
    flags+=("-p")
    local_nonpersistent_flags+=("--processed")
    flags+=("--set=")
    local_nonpersistent_flags+=("--set=")
    flags+=("--sleeping")
    flags+=("-s")
    local_nonpersistent_flags+=("--sleeping")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_make-sr-symlinks()
{
    last_command="l3t_make-sr-symlinks"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--bug=")
    two_word_flags+=("-b")
    local_nonpersistent_flags+=("--bug=")
    flags+=("--config=")
    local_nonpersistent_flags+=("--config=")
    flags+=("--dest=")
    two_word_flags+=("-d")
    local_nonpersistent_flags+=("--dest=")
    flags+=("--force")
    local_nonpersistent_flags+=("--force")
    flags+=("--incident=")
    two_word_flags+=("-i")
    local_nonpersistent_flags+=("--incident=")
    flags+=("--set=")
    local_nonpersistent_flags+=("--set=")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_next()
{
    last_command="l3t_next"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--active")
    flags+=("-a")
    local_nonpersistent_flags+=("--active")
    flags+=("--backup")
    flags+=("-b")
    local_nonpersistent_flags+=("--backup")
    flags+=("--closed")
    flags+=("-c")
    local_nonpersistent_flags+=("--closed")
    flags+=("--config=")
    local_nonpersistent_flags+=("--config=")
    flags+=("--new")
    flags+=("-n")
    local_nonpersistent_flags+=("--new")
    flags+=("--processed")
    flags+=("-p")
    local_nonpersistent_flags+=("--processed")
    flags+=("--set=")
    local_nonpersistent_flags+=("--set=")
    flags+=("--skip-new")
    flags+=("-N")
    local_nonpersistent_flags+=("--skip-new")
    flags+=("--sleeping")
    flags+=("-s")
    local_nonpersistent_flags+=("--sleeping")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_open-bug-web()
{
    last_command="l3t_open-bug-web"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--bug=")
    two_word_flags+=("-b")
    local_nonpersistent_flags+=("--bug=")
    flags+=("--config=")
    local_nonpersistent_flags+=("--config=")
    flags+=("--incident=")
    two_word_flags+=("-i")
    local_nonpersistent_flags+=("--incident=")
    flags+=("--set=")
    local_nonpersistent_flags+=("--set=")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_open-incident-web()
{
    last_command="l3t_open-incident-web"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--bug=")
    two_word_flags+=("-b")
    local_nonpersistent_flags+=("--bug=")
    flags+=("--config=")
    local_nonpersistent_flags+=("--config=")
    flags+=("--incident=")
    two_word_flags+=("-i")
    local_nonpersistent_flags+=("--incident=")
    flags+=("--set=")
    local_nonpersistent_flags+=("--set=")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_search-incidents()
{
    last_command="l3t_search-incidents"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--agent=")
    two_word_flags+=("-a")
    local_nonpersistent_flags+=("--agent=")
    flags+=("--bug=")
    two_word_flags+=("-b")
    local_nonpersistent_flags+=("--bug=")
    flags+=("--config=")
    local_nonpersistent_flags+=("--config=")
    flags+=("--customer=")
    two_word_flags+=("-c")
    local_nonpersistent_flags+=("--customer=")
    flags+=("--expr=")
    two_word_flags+=("-E")
    local_nonpersistent_flags+=("--expr=")
    flags+=("--limit=")
    two_word_flags+=("-L")
    local_nonpersistent_flags+=("--limit=")
    flags+=("--list")
    flags+=("-l")
    local_nonpersistent_flags+=("--list")
    flags+=("--not-running")
    flags+=("-R")
    local_nonpersistent_flags+=("--not-running")
    flags+=("--run=")
    local_nonpersistent_flags+=("--run=")
    flags+=("--set=")
    local_nonpersistent_flags+=("--set=")
    flags+=("--sr=")
    local_nonpersistent_flags+=("--sr=")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_sleep()
{
    last_command="l3t_sleep"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--bug=")
    two_word_flags+=("-b")
    local_nonpersistent_flags+=("--bug=")
    flags+=("--incident=")
    two_word_flags+=("-i")
    local_nonpersistent_flags+=("--incident=")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_sr()
{
    last_command="l3t_sr"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--sr=")
    two_word_flags+=("-s")
    local_nonpersistent_flags+=("--sr=")

    must_have_one_flag=()
    must_have_one_flag+=("--sr=")
    must_have_one_flag+=("-s")
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_version()
{
    last_command="l3t_version"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()


    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_zzz()
{
    last_command="l3t_zzz"

    command_aliases=()

    commands=()

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()

    flags+=("--bug=")
    two_word_flags+=("-b")
    local_nonpersistent_flags+=("--bug=")
    flags+=("--incident=")
    two_word_flags+=("-i")
    local_nonpersistent_flags+=("--incident=")

    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

_l3t_root_command()
{
    last_command="l3t"

    command_aliases=()

    commands=()
    commands+=("accept")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("ac")
        aliashash["ac"]="accept"
        command_aliases+=("l3ac")
        aliashash["l3ac"]="accept"
    fi
    commands+=("assign")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("as")
        aliashash["as"]="assign"
        command_aliases+=("l3as")
        aliashash["l3as"]="assign"
    fi
    commands+=("config")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("showrc")
        aliashash["showrc"]="config"
    fi
    commands+=("create-ptf")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("ptf-create")
        aliashash["ptf-create"]="create-ptf"
        command_aliases+=("ptfc")
        aliashash["ptfc"]="create-ptf"
        command_aliases+=("ptfs")
        aliashash["ptfs"]="create-ptf"
    fi
    commands+=("edit-bug")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("be")
        aliashash["be"]="edit-bug"
        command_aliases+=("bze")
        aliashash["bze"]="edit-bug"
        command_aliases+=("edit-bug")
        aliashash["edit-bug"]="edit-bug"
    fi
    commands+=("expand-bug")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("eb")
        aliashash["eb"]="expand-bug"
        command_aliases+=("l3t-expand-bug")
        aliashash["l3t-expand-bug"]="expand-bug"
    fi
    commands+=("expand-incident")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("ei")
        aliashash["ei"]="expand-incident"
        command_aliases+=("l3t-expand-incident")
        aliashash["l3t-expand-incident"]="expand-incident"
    fi
    commands+=("get-attachment")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("att")
        aliashash["att"]="get-attachment"
        command_aliases+=("bzag")
        aliashash["bzag"]="get-attachment"
    fi
    commands+=("get-bug")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("b")
        aliashash["b"]="get-bug"
        command_aliases+=("bug")
        aliashash["bug"]="get-bug"
        command_aliases+=("bzg")
        aliashash["bzg"]="get-bug"
    fi
    commands+=("get-incident")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("i")
        aliashash["i"]="get-incident"
        command_aliases+=("l3g")
        aliashash["l3g"]="get-incident"
    fi
    commands+=("get-sg-bug")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("l3bz")
        aliashash["l3bz"]="get-sg-bug"
        command_aliases+=("sgb")
        aliashash["sgb"]="get-sg-bug"
    fi
    commands+=("ls")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("l")
        aliashash["l"]="ls"
        command_aliases+=("l3ls")
        aliashash["l3ls"]="ls"
    fi
    commands+=("make-sr-symlinks")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("l3t-make-sr-symlinks")
        aliashash["l3t-make-sr-symlinks"]="make-sr-symlinks"
        command_aliases+=("lsr")
        aliashash["lsr"]="make-sr-symlinks"
        command_aliases+=("srl")
        aliashash["srl"]="make-sr-symlinks"
    fi
    commands+=("next")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("n")
        aliashash["n"]="next"
        command_aliases+=("writerblock")
        aliashash["writerblock"]="next"
    fi
    commands+=("open-bug-web")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("bzo")
        aliashash["bzo"]="open-bug-web"
        command_aliases+=("ob")
        aliashash["ob"]="open-bug-web"
    fi
    commands+=("open-incident-web")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("l3o")
        aliashash["l3o"]="open-incident-web"
        command_aliases+=("oi")
        aliashash["oi"]="open-incident-web"
    fi
    commands+=("search-incidents")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("l3se")
        aliashash["l3se"]="search-incidents"
        command_aliases+=("se")
        aliashash["se"]="search-incidents"
        command_aliases+=("search")
        aliashash["search"]="search-incidents"
    fi
    commands+=("sleep")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("l3s")
        aliashash["l3s"]="sleep"
        command_aliases+=("s")
        aliashash["s"]="sleep"
    fi
    commands+=("sr")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("l3tsrg")
        aliashash["l3tsrg"]="sr"
        command_aliases+=("srg")
        aliashash["srg"]="sr"
    fi
    commands+=("version")
    commands+=("zzz")
    if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
        command_aliases+=("l3z")
        aliashash["l3z"]="zzz"
        command_aliases+=("short-sleep")
        aliashash["short-sleep"]="zzz"
    fi

    flags=()
    two_word_flags=()
    local_nonpersistent_flags=()
    flags_with_completion=()
    flags_completion=()


    must_have_one_flag=()
    must_have_one_noun=()
    noun_aliases=()
}

__start_l3t()
{
    local cur prev words cword
    declare -A flaghash 2>/dev/null || :
    declare -A aliashash 2>/dev/null || :
    if declare -F _init_completion >/dev/null 2>&1; then
        _init_completion -s || return
    else
        __l3t_init_completion -n "=" || return
    fi

    local c=0
    local flags=()
    local two_word_flags=()
    local local_nonpersistent_flags=()
    local flags_with_completion=()
    local flags_completion=()
    local commands=("l3t")
    local must_have_one_flag=()
    local must_have_one_noun=()
    local last_command
    local nouns=()

    __l3t_handle_word
}

if [[ $(type -t compopt) = "builtin" ]]; then
    complete -o default -F __start_l3t l3t
else
    complete -o default -o nospace -F __start_l3t l3t
fi

# ex: ts=4 sw=4 et filetype=sh