# Volt auto completion script
#
# Part of the Volt package


_volt()
{
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    opts="help ext init gen serve demo version"

    case "${prev}" in
        help)
            COMPREPLY=( $(compgen -W "ext init gen serve demo version" -- ${cur}) )
            ;;
        ext)
            case "${cur}" in
                -*)
                    local subopts="--builtin"
                    COMPREPLY=( $(compgen -W "${subopts}" -- ${cur}) )
                    ;;
                *)
                    local subopts="engine plugin widget"
                    COMPREPLY=( $(compgen -W "${subopts}" -- ${cur}) )
                    ;;
            esac
            ;;
        gen)
            case "${cur}" in
                -*)
                    local subopts="--dir"
                    COMPREPLY=( $(compgen -W "${subopts}" -- ${cur}) )
                    ;;
                *)
                    _filedir
                    ;;
            esac
            ;;
        version)
            COMPREPLY=()
            ;;
        serve)
            case "${cur}" in
                -*)
                    local subopts="--port --help"
                    COMPREPLY=( $(compgen -W "${subopts}" -- ${cur}) )
                    ;;
                *)
                    _filedir
                    ;;
            esac
            ;;
        *)
            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
            ;;
    esac

}
complete -F _volt volt
