#compdef thumbs

autoload -U is-at-least

_thumbs() {
    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[@]}" : \
'*-v[Pass for more log output]' \
'*--verbose[Pass for more log output]' \
'(-v --verbose)*-q[Pass for less log output]' \
'(-v --verbose)*--quiet[Pass for less log output]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_thumbs_commands" \
"*::: :->xtask" \
&& ret=0
    case $state in
    (xtask)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:thumbs-command-$line[1]:"
        case $line[1] in
            (delete)
_arguments "${_arguments_options[@]}" : \
'-l+[Only delete thumbnails for files that haven'\''t been accessed in the given time]:LAST_ACCESSED:_default' \
'--last-accessed=[Only delete thumbnails for files that haven'\''t been accessed in the given time]:LAST_ACCESSED:_default' \
'-r[Recurse through directories]' \
'--recursive[Recurse through directories]' \
'-f[Do not prompt and actually delete thumbnails]' \
'--force[Do not prompt and actually delete thumbnails]' \
'-a[Include hidden files and directories]' \
'--all[Include hidden files and directories]' \
'*-v[Pass for more log output]' \
'*--verbose[Pass for more log output]' \
'(-v --verbose)*-q[Pass for less log output]' \
'(-v --verbose)*--quiet[Pass for less log output]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::files -- File whose thumbnails to delete, or `-` for reading a file path from standard input:_files' \
&& ret=0
;;
(locate)
_arguments "${_arguments_options[@]}" : \
'*-v[Pass for more log output]' \
'*--verbose[Pass for more log output]' \
'(-v --verbose)*-q[Pass for less log output]' \
'(-v --verbose)*--quiet[Pass for less log output]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
':file -- File whose thumbnails are to be found, or `-` to read a file path from standard input:_files' \
&& ret=0
;;
(cleanup)
_arguments "${_arguments_options[@]}" : \
'-f[Do not prompt and actually delete thumbnails]' \
'--force[Do not prompt and actually delete thumbnails]' \
'*-v[Pass for more log output]' \
'*--verbose[Pass for more log output]' \
'(-v --verbose)*-q[Pass for less log output]' \
'(-v --verbose)*--quiet[Pass for less log output]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::glob -- Include or exclude files and directories that match the given globs. Can be used multiple times. Globbing rules match `.gitignore` globs. Precede a glob with a `!` to exclude it:_default' \
&& ret=0
;;
(info)
_arguments "${_arguments_options[@]}" : \
'*-v[Pass for more log output]' \
'*--verbose[Pass for more log output]' \
'(-v --verbose)*-q[Pass for less log output]' \
'(-v --verbose)*--quiet[Pass for less log output]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::file -- A file to provide information about, or `-` to read a file path from standard input:_default' \
&& ret=0
;;
        esac
    ;;
esac
}

(( $+functions[_thumbs_commands] )) ||
_thumbs_commands() {
    local commands; commands=(
'delete:Delete the thumbnails for the given files' \
'locate:Print the path of thumbnails for the given files' \
'cleanup:Find thumbnails for files that no longer exist and optionally delete them' \
'info:Show information about a file'\''s thumbnails or the thumbnail cache' \
    )
    _describe -t commands 'thumbs commands' commands "$@"
}
(( $+functions[_thumbs__subcmd__cleanup_commands] )) ||
_thumbs__subcmd__cleanup_commands() {
    local commands; commands=()
    _describe -t commands 'thumbs cleanup commands' commands "$@"
}
(( $+functions[_thumbs__subcmd__delete_commands] )) ||
_thumbs__subcmd__delete_commands() {
    local commands; commands=()
    _describe -t commands 'thumbs delete commands' commands "$@"
}
(( $+functions[_thumbs__subcmd__info_commands] )) ||
_thumbs__subcmd__info_commands() {
    local commands; commands=()
    _describe -t commands 'thumbs info commands' commands "$@"
}
(( $+functions[_thumbs__subcmd__locate_commands] )) ||
_thumbs__subcmd__locate_commands() {
    local commands; commands=()
    _describe -t commands 'thumbs locate commands' commands "$@"
}

if [ "$funcstack[1]" = "_thumbs" ]; then
    _thumbs "$@"
else
    compdef _thumbs thumbs
fi
