#compdef ingredients

autoload -U is-at-least

_ingredients() {
    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[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
":: :_ingredients_commands" \
"*::: :->ingredients" \
&& ret=0
    case $state in
    (ingredients)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ingredients-command-$line[1]:"
        case $line[1] in
            (report)
_arguments "${_arguments_options[@]}" : \
'--format=[Output format]:FORMAT:(plain verbose json)' \
'--severity=[Minimum severity]:SEVERITY:((fatal\:"Fatal problems that prevent further processing"
error\:"Probable errors that require manual investigation"
warning\:"Potential issues that might or might not be harmless"
info\:"Additional information provided for some situations"
debug\:"Information only useful for debugging purposes"))' \
'-f+[Path to local crate archive to use instead of downloading from crates.io]:FILE:_files' \
'--file=[Path to local crate archive to use instead of downloading from crates.io]:FILE:_files' \
'-u+[Provide repository URL if package.repository is missing or wrong]:WITH_REPOSITORY:_default' \
'--with-repository=[Provide repository URL if package.repository is missing or wrong]:WITH_REPOSITORY:_default' \
'-p+[Provide "path in VCS" if \`.cargo_vcs_info.json\` is missing or incomplete]:WITH_PATH_IN_VCS:_default' \
'--with-path-in-vcs=[Provide "path in VCS" if \`.cargo_vcs_info.json\` is missing or incomplete]:WITH_PATH_IN_VCS:_default' \
'-r+[Provide VCS ref if \`.cargo_vcs_info.json\` is missing or incomplete]:WITH_VCS_REF:_default' \
'--with-vcs-ref=[Provide VCS ref if \`.cargo_vcs_info.json\` is missing or incomplete]:WITH_VCS_REF:_default' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':name -- Name of the crate:_default' \
':version -- Version of the crate:_default' \
&& ret=0
;;
(diff)
_arguments "${_arguments_options[@]}" : \
'--format=[Output format]:FORMAT:(plain verbose json)' \
'--severity=[Minimum severity]:SEVERITY:((fatal\:"Fatal problems that prevent further processing"
error\:"Probable errors that require manual investigation"
warning\:"Potential issues that might or might not be harmless"
info\:"Additional information provided for some situations"
debug\:"Information only useful for debugging purposes"))' \
'--old-file=[Path to local crate archive for old crate version]:OLD_FILE:_files' \
'--new-file=[Path to local crate archive for new crate version]:NEW_FILE:_files' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':name -- Name of the crate:_default' \
':old_version -- Old version of the crate:_default' \
':new_version -- New version of the crate:_default' \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':shell:(bash fish zsh nushell)' \
&& ret=0
;;
        esac
    ;;
esac
}

(( $+functions[_ingredients_commands] )) ||
_ingredients_commands() {
    local commands; commands=(
'report:Compare a crate against the contents of the upstream version control system' \
'diff:Compare two versions of a crate' \
'completions:' \
    )
    _describe -t commands 'ingredients commands' commands "$@"
}
(( $+functions[_ingredients__completions_commands] )) ||
_ingredients__completions_commands() {
    local commands; commands=()
    _describe -t commands 'ingredients completions commands' commands "$@"
}
(( $+functions[_ingredients__diff_commands] )) ||
_ingredients__diff_commands() {
    local commands; commands=()
    _describe -t commands 'ingredients diff commands' commands "$@"
}
(( $+functions[_ingredients__report_commands] )) ||
_ingredients__report_commands() {
    local commands; commands=()
    _describe -t commands 'ingredients report commands' commands "$@"
}

if [ "$funcstack[1]" = "_ingredients" ]; then
    _ingredients "$@"
else
    compdef _ingredients ingredients
fi
