# Bash completion for t2timeline

_t2timeline() {
    local cur prev words 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
        -e|-ts|-ls|-ks|-v|-ws|-tx|-ty|-t|-s)
            return
            ;;
        --gif|--jpeg|--png|--svg)
            if type -t _filedir &> /dev/null; then
                _filedir
            else
                compopt -o filenames 2> /dev/null
                COMPREPLY=($(compgen -f -- "$cur"))
            fi
            return
            ;;
    esac

    if [[ "$cur" == -* ]]; then
        COMPREPLY=($(compgen -W "$(_parse_help "$T2HOME/scripts/t2timeline")" -- "$cur"))
    elif type -t _filedir &> /dev/null; then
        _filedir
    else
        compopt -o filenames 2> /dev/null
        COMPREPLY=($(compgen -f -- "$cur"))
    fi
}

complete -F _t2timeline t2timeline
