#compdef paccat

autoload -U is-at-least

_paccat() {
    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[@]}" : \
'-r+[Set an alternative root directory]:path: ' \
'--root=[Set an alternative root directory]:path: ' \
'-b+[Set an alternative database location]:path: ' \
'--dbpath=[Set an alternative database location]:path: ' \
'--config=[Use an alternative pacman.conf]:file: ' \
'--color=[Specify when to enable coloring]:when:(auto always never)' \
'--cachedir=[Set an alternative cache directory]:path: ' \
'-F[Use files database to search for files before deciding to download]' \
'--files[Use files database to search for files before deciding to download]' \
'(-F --files)-Q[Use local database to search for files before deciding to download]' \
'(-F --files)--query[Use local database to search for files before deciding to download]' \
'*-y[Download fresh package databases from the server]' \
'*--refresh[Download fresh package databases from the server]' \
'-a[Print all matches of files instead of just the first]' \
'--all[Print all matches of files instead of just the first]' \
'-x[Enable searching using regular expressions]' \
'--regex[Enable searching using regular expressions]' \
'--binary[Print binary files]' \
'-X[Filter results to executable files]' \
'--executable[Filter results to executable files]' \
'-e[Extract matched files to the current directory]' \
'--extract[Extract matched files to the current directory]' \
'(-e --extract)-i[Install matched files to the system]' \
'(-e --extract)--install[Install matched files to the system]' \
'-l[Print file names instead of file content]' \
'--list[Print file names instead of file content]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::targets -- List of packages, package files, or package urls:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_paccat" ]; then
    _paccat "$@"
else
    compdef _paccat paccat
fi
