#compdef pkgcruft

autoload -U is-at-least

_pkgcruft() {
    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=[enable/disable color support]:BOOL:(true false)' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_pkgcruft_commands" \
"*::: :->pkgcruft" \
&& ret=0
    case $state in
    (pkgcruft)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:pkgcruft-command-$line[1]:"
        case $line[1] in
            (completion)
_arguments "${_arguments_options[@]}" : \
'-d+[Target directory for completion files]:DIR:_default' \
'--dir=[Target directory for completion files]:DIR:_default' \
'--color=[enable/disable color support]:BOOL:(true false)' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
'::shell -- Target shell:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(diff)
_arguments "${_arguments_options[@]}" : \
'*-r+[Restrict by report target]:TARGET[,...]:_default' \
'*--reports=[Restrict by report target]:TARGET[,...]:_default' \
'*-p+[Package restrictions]:PKG[,...]:_default' \
'*--pkgs=[Package restrictions]:PKG[,...]:_default' \
'--color=[enable/disable color support]:BOOL:(true false)' \
'-s[Sort reports]' \
'--sort[Sort reports]' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
':old -- Old file path:_files' \
':new -- New file path:_files' \
&& ret=0
;;
(ignore)
_arguments "${_arguments_options[@]}" : \
'--repo=[Target repo]:REPO:_default' \
'--color=[enable/disable color support]:BOOL:(true false)' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
'*::targets -- Target packages or paths:_default' \
&& ret=0
;;
(replay)
_arguments "${_arguments_options[@]}" : \
'*-r+[Restrict by report target]:TARGET[,...]:_default' \
'*--reports=[Restrict by report target]:TARGET[,...]:_default' \
'*-p+[Package restrictions]:PKG[,...]:_default' \
'*--pkgs=[Package restrictions]:PKG[,...]:_default' \
'*-S+[Restrict by scope]:SCOPE[,...]:(version package category repo)' \
'*--scopes=[Restrict by scope]:SCOPE[,...]:(version package category repo)' \
'-R+[Reporter to use]:REPORTER:(count fancy format json null simple stats time)' \
'--reporter=[Reporter to use]:REPORTER:(count fancy format json null simple stats time)' \
'--format=[Format string for the format reporter]:FORMAT:_default' \
'--stats=[Sorting variant for the stats reporter]:STATS:(name count level)' \
'--color=[enable/disable color support]:BOOL:(true false)' \
'-s[Sort reports]' \
'--sort[Sort reports]' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
'*::files -- Target file paths:_files' \
&& ret=0
;;
(scan)
_arguments "${_arguments_options[@]}" : \
'*-f+[Enable package filtering]:FILTER[,...]:_default' \
'*--filters=[Enable package filtering]:FILTER[,...]:_default' \
'-j+[Parallel jobs to run]:JOBS:_default' \
'--jobs=[Parallel jobs to run]:JOBS:_default' \
'*--exit=[Exit status triggers]' \
'--repo=[Target repo]:REPO:_default' \
'-R+[Reporter to use]:REPORTER:(count fancy format json null simple stats time)' \
'--reporter=[Reporter to use]:REPORTER:(count fancy format json null simple stats time)' \
'--format=[Format string for the format reporter]:FORMAT:_default' \
'--stats=[Sorting variant for the stats reporter]:STATS:(name count level)' \
'*-r+[Restrict by report target]:TARGET[,...]:_default' \
'*--reports=[Restrict by report target]:TARGET[,...]:_default' \
'--color=[enable/disable color support]:BOOL:(true false)' \
'-F[Disregard ignore settings]' \
'--force[Disregard ignore settings]' \
'-s[Output reports in sorted order]' \
'--sort[Output reports in sorted order]' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
'*::targets -- Target packages or paths:_default' \
&& ret=0
;;
(show)
_arguments "${_arguments_options[@]}" : \
'--color=[enable/disable color support]:BOOL:(true false)' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
":: :_pkgcruft__show_commands" \
"*::: :->show" \
&& ret=0

    case $state in
    (show)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:pkgcruft-show-command-$line[1]:"
        case $line[1] in
            (checks)
_arguments "${_arguments_options[@]}" : \
'--repo=[Target repo]' \
'--color=[enable/disable color support]:BOOL:(true false)' \
'-i[Output extended information]' \
'--info[Output extended information]' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(reports)
_arguments "${_arguments_options[@]}" : \
'--repo=[Target repo]' \
'*-r+[Restrict by report target]:TARGET[,...]:_default' \
'*--reports=[Restrict by report target]:TARGET[,...]:_default' \
'--color=[enable/disable color support]:BOOL:(true false)' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'(-v --verbose)*-q[Decrease logging verbosity]' \
'(-v --verbose)*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_pkgcruft_commands] )) ||
_pkgcruft_commands() {
    local commands; commands=(
'completion:Generate shell completion' \
'diff:Compare reports' \
'ignore:Show ignore information' \
'replay:Replay reports' \
'scan:Scan for QA issues' \
'show:Show various information' \
    )
    _describe -t commands 'pkgcruft commands' commands "$@"
}
(( $+functions[_pkgcruft__completion_commands] )) ||
_pkgcruft__completion_commands() {
    local commands; commands=()
    _describe -t commands 'pkgcruft completion commands' commands "$@"
}
(( $+functions[_pkgcruft__diff_commands] )) ||
_pkgcruft__diff_commands() {
    local commands; commands=()
    _describe -t commands 'pkgcruft diff commands' commands "$@"
}
(( $+functions[_pkgcruft__ignore_commands] )) ||
_pkgcruft__ignore_commands() {
    local commands; commands=()
    _describe -t commands 'pkgcruft ignore commands' commands "$@"
}
(( $+functions[_pkgcruft__replay_commands] )) ||
_pkgcruft__replay_commands() {
    local commands; commands=()
    _describe -t commands 'pkgcruft replay commands' commands "$@"
}
(( $+functions[_pkgcruft__scan_commands] )) ||
_pkgcruft__scan_commands() {
    local commands; commands=()
    _describe -t commands 'pkgcruft scan commands' commands "$@"
}
(( $+functions[_pkgcruft__show_commands] )) ||
_pkgcruft__show_commands() {
    local commands; commands=(
'checks:Show checks' \
'reports:Show reports' \
    )
    _describe -t commands 'pkgcruft show commands' commands "$@"
}
(( $+functions[_pkgcruft__show__checks_commands] )) ||
_pkgcruft__show__checks_commands() {
    local commands; commands=()
    _describe -t commands 'pkgcruft show checks commands' commands "$@"
}
(( $+functions[_pkgcruft__show__reports_commands] )) ||
_pkgcruft__show__reports_commands() {
    local commands; commands=()
    _describe -t commands 'pkgcruft show reports commands' commands "$@"
}

if [ "$funcstack[1]" = "_pkgcruft" ]; then
    _pkgcruft "$@"
else
    compdef _pkgcruft pkgcruft
fi
