#compdef dotnet

_dotnet() {
    local -a args cmds
    for c in $(dotnet complete "$words")
    do
        if [[ $c =~ ^[-/] ]]
        then
            args+=$c
        else
            cmds+=$c
        fi
    done

    if (( ${#args} + ${#cmds} > 0 ))
    then
        _values command $cmds
        _values option $args
    else
        _arguments '*::arguments: _normal'
    fi

}

_dotnet $@

# vim: ft=zsh
