# 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 init gen serve switch demo version"

    case "${prev}" in
        help)
            COMPREPLY=( $(compgen -W "init gen serve switch demo version" -- ${cur}) )
            ;;
        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
