# Bash completion for t2b2t

_t2b2t() {
    local cur prev word cword

    if type -t _init_completion &> /dev/null; then
        _init_completion -n = || return
    else
        COMPREPLY=()
        cur="${COMP_WORDS[COMP_CWORD]}"
        prev="${COMP_WORDS[COMP_CWORD-1]}"
    fi

    case "$prev" in
        -r|-w)
            if type -t _filedir &> /dev/null; then
                _filedir
            else
                compopt -o filenames 2> /dev/null
                COMPREPLY=($(compgen -f -- "$cur"))
            fi
            return
            ;;
    esac

    local args=(
        -r -w -j -c -n -p -P -l -h
    )

    COMPREPLY=($(compgen -W "${args[*]}" -- "$cur"))
}

complete -F _t2b2t t2b2t
