#compdef git-cliff

autoload -U is-at-least

_git-cliff() {
    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+[Sets the configuration file]:PATH: ' \
'--config=[Sets the configuration file]:PATH: ' \
'-w+[Sets the working directory]:PATH: ' \
'--workdir=[Sets the working directory]:PATH: ' \
'-r+[Sets the git repository]:PATH: ' \
'--repository=[Sets the git repository]:PATH: ' \
'*--include-path=[Sets the path to include related commits]:PATTERN: ' \
'*--exclude-path=[Sets the path to exclude related commits]:PATTERN: ' \
'*--with-commit=[Sets custom commit messages to include in the changelog]:MSG: ' \
'-p+[Prepends entries to the given changelog file]:PATH: ' \
'--prepend=[Prepends entries to the given changelog file]:PATH: ' \
'-o+[Writes output to the given file]:PATH: ' \
'--output=[Writes output to the given file]:PATH: ' \
'-t+[Sets the tag for the latest version]:TAG: ' \
'--tag=[Sets the tag for the latest version]:TAG: ' \
'-b+[Sets the template for the changelog body]:TEMPLATE: ' \
'--body=[Sets the template for the changelog body]:TEMPLATE: ' \
'-s+[Strips the given parts from the changelog]:PART:(header footer all)' \
'--strip=[Strips the given parts from the changelog]:PART:(header footer all)' \
'--sort=[Sets sorting of the commits inside sections]:SORT:(oldest newest)' \
'*-v[Increases the logging verbosity]' \
'*--verbose[Increases the logging verbosity]' \
'-i[Writes the default configuration file to cliff.toml]' \
'--init[Writes the default configuration file to cliff.toml]' \
'-l[Processes the commits starting from the latest tag]' \
'--latest[Processes the commits starting from the latest tag]' \
'--current[Processes the commits that belong to the current tag]' \
'-u[Processes the commits that do not belong to a tag]' \
'--unreleased[Processes the commits that do not belong to a tag]' \
'--date-order[Sorts the tags chronologically]' \
'--context[Prints changelog context as JSON]' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
'::range -- Sets the commit range to process:' \
&& ret=0
}

(( $+functions[_git-cliff_commands] )) ||
_git-cliff_commands() {
    local commands; commands=()
    _describe -t commands 'git-cliff commands' commands "$@"
}

_git-cliff "$@"
