#compdef rmdir

autoload -U is-at-least

_rmdir() {
    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[@]}" : \
'--ignore-fail-on-non-empty[ignore each failure that is solely because a directory is non-empty]' \
'-p[remove DIRECTORY and its ancestors; e.g., '\''rmdir -p a/b/c'\'' is similar to rmdir a/b/c a/b a]' \
'--parents[remove DIRECTORY and its ancestors; e.g., '\''rmdir -p a/b/c'\'' is similar to rmdir a/b/c a/b a]' \
'-v[output a diagnostic for every directory processed]' \
'--verbose[output a diagnostic for every directory processed]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::dirs:_files -/' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_rmdir" ]; then
    _rmdir "$@"
else
    compdef _rmdir rmdir
fi
