#compdef cargo-doc2readme

autoload -U is-at-least

_cargo-doc2readme() {
    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[@]}" : \
'-c+[Path to config file. By default, doc2readme.toml and .doc2readme.toml are read if they exist]:CONFIG_FILE:_files' \
'--config=[Path to config file. By default, doc2readme.toml and .doc2readme.toml are read if they exist]:CONFIG_FILE:_files' \
'--manifest-path=[Path to Cargo.toml]:MANIFEST_PATH:_files' \
'-p+[Package to read]:PACKAGE:_default' \
'--package=[Package to read]:PACKAGE:_default' \
'-o+[Output File, README.md by default]:OUT:_files' \
'--out=[Output File, README.md by default]:OUT:_files' \
'-t+[Template File. This is processed by minijinja. Look at the source code for cargo-doc2readme for an example. By default, README.j2 is read if it exists]:TEMPLATE:_files' \
'--template=[Template File. This is processed by minijinja. Look at the source code for cargo-doc2readme for an example. By default, README.j2 is read if it exists]:TEMPLATE:_files' \
'-F+[Space or comma separated list of features to activate. This will be ignored unless \`--expand-macros\` is enabled, in which case it is being passed to cargo]:FEATURES:_default' \
'--features=[Space or comma separated list of features to activate. This will be ignored unless \`--expand-macros\` is enabled, in which case it is being passed to cargo]:FEATURES:_default' \
'--expand-macros[Use nightly rustc to expand macros prior to reading the source. This is necessary if you use function-like macros in doc attributes, as introduced in Rust 1.54]' \
'--all-features[Activate all available features. This will be ignored unless \`--expand-macros\` is enabled, in which case it is being passed to cargo]' \
'--no-default-features[Do not activate the \`default\` feature. This will be ignored unless \`--expand-macros\` is enabled, in which case it is being passed to cargo]' \
'(--lib)--bin[Prefer binary targets over library targets for rustdoc source]' \
'(--bin)--lib[Prefer library targets over binary targets for rustdoc source. This is the default]' \
'--check[Verify that the output file is (reasonably) up to date, and fail if it needs updating. The output file will not be changed]' \
'-v[Enable verbose output]' \
'--verbose[Enable verbose output]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
}

(( $+functions[_cargo-doc2readme_commands] )) ||
_cargo-doc2readme_commands() {
    local commands; commands=()
    _describe -t commands 'cargo-doc2readme commands' commands "$@"
}

if [ "$funcstack[1]" = "_cargo-doc2readme" ]; then
    _cargo-doc2readme "$@"
else
    compdef _cargo-doc2readme cargo-doc2readme
fi
