#compdef pkgdb pkg_which

(( $+functions[_pkg_which_files] )) ||
_pkg_which_files() {
    local ret=1

    _files "$@" && ret=0
    _command_names -e "$@" && ret=0

    return ret
}

_arguments -s \
 '-f[force to update database regardless of timestamps]' \
 '-F[interactively fix package registry]' \
 '*-o:pkgname to look up the origin of:compadd - ${PKG_DBDIR\:-/var/db/pkg}/*(/\:t)' \
 '-q[do not read pkgtools.conf]' \
 '*-s:dependency substitution; /from/to/:' \
 '-u[update packages database]' \
 '-v[be verbose]' \
 '*:file:_pkg_which_files'
