#compdef dysk

autoload -U is-at-least

_dysk() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" : \
'--color=[whether to have styles and colors]:color:(auto yes no)' \
'--remote-stats=[fetch stats of remote volumes]:choice:(auto yes no)' \
'-c+[columns, eg \`-c +inodes\` or \`-c id+dev+default\`]:columns:_default' \
'--cols=[columns, eg \`-c +inodes\` or \`-c id+dev+default\`]:columns:_default' \
'-f+[filter, eg \`-f '\''(size<35G | remote=false) & type=xfs'\''\`]:expr:_default' \
'--filter=[filter, eg \`-f '\''(size<35G | remote=false) & type=xfs'\''\`]:expr:_default' \
'-s+[sort, eg \`inodes\`, \`type-desc\`, or \`size-asc\`]:sort:_default' \
'--sort=[sort, eg \`inodes\`, \`type-desc\`, or \`size-asc\`]:sort:_default' \
'-u+[units\: \`SI\` (SI norm), \`binary\` (1024 based), or \`bytes\` (raw number)]:unit:_default' \
'--units=[units\: \`SI\` (SI norm), \`binary\` (1024 based), or \`bytes\` (raw number)]:unit:_default' \
'--csv-separator=[CSV separator]:sep:_default' \
'--strategy=[strategy to use to find information, when several are available]:STRATEGY:_default' \
'--timeout=[timeout to use for some operations, eg \`10s\` or \`5ms\`]:TIMEOUT:_default' \
'--bar-width=[width of the progress bar in the '\''use'\'' and '\''inodes'\'' columns]:width:_default' \
'--help[print help information]' \
'--version[print the version]' \
'-a[show all mount points]' \
'--all[show all mount points]' \
'--ascii[use only ASCII characters for table rendering]' \
'--list-cols[list the column names which can be used in -s, -f, or -c]' \
'-j[output as JSON]' \
'--json[output as JSON]' \
'--csv[output as CSV]' \
'::path -- if provided, only the device holding this path will be shown:_files' \
&& ret=0
}

(( $+functions[_dysk_commands] )) ||
_dysk_commands() {
    local commands; commands=()
    _describe -t commands 'dysk commands' commands "$@"
}

if [ "$funcstack[1]" = "_dysk" ]; then
    _dysk "$@"
else
    compdef _dysk dysk
fi
