#compdef cog

autoload -U is-at-least

_cog() {
    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 information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'*-v[The level of verbosity: -v for ERROR, -vv for WARNING, -vvv for INFO]' \
'*--verbose[The level of verbosity: -v for ERROR, -vv for WARNING, -vvv for INFO]' \
'-q[Silence all output, no matter the value of verbosity]' \
'--quiet[Silence all output, no matter the value of verbosity]' \
":: :_cog_commands" \
"*::: :->Cog" \
&& ret=0
    case $state in
    (Cog)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:cog-command-$line[1]:"
        case $line[1] in
            (check)
_arguments "${_arguments_options[@]}" \
'-l[Check commit history, starting from the latest tag to HEAD]' \
'--from-latest-tag[Check commit history, starting from the latest tag to HEAD]' \
'-i[Ignore merge commits messages]' \
'--ignore-merge-commits[Ignore merge commits messages]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(commit)
_arguments "${_arguments_options[@]}" \
'-B[Create a BREAKING CHANGE commit]' \
'--breaking-change[Create a BREAKING CHANGE commit]' \
'-e[Open commit message in an editor]' \
'--edit[Open commit message in an editor]' \
'-s[Sign this commit]' \
'--sign[Sign this commit]' \
'-h[Print help information]' \
'--help[Print help information]' \
':type -- Conventional commit type:(refactor chore test feat docs style perf revert fix build ci)' \
':message -- Commit description:' \
'::scope -- Conventional commit scope:' \
&& ret=0
;;
(edit)
_arguments "${_arguments_options[@]}" \
'-l[Edit non conventional commits, starting from the latest tag to HEAD]' \
'--from-latest-tag[Edit non conventional commits, starting from the latest tag to HEAD]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(log)
_arguments "${_arguments_options[@]}" \
'*-t+[filter on commit type]:type: ' \
'*--type=[filter on commit type]:type: ' \
'*-a+[filter on commit author]:AUTHOR: ' \
'*--author=[filter on commit author]:AUTHOR: ' \
'*-s+[filter on commit scope]:SCOPE: ' \
'*--scope=[filter on commit scope]:SCOPE: ' \
'-B[filter BREAKING CHANGE commits]' \
'--breaking-change[filter BREAKING CHANGE commits]' \
'-e[omit error on the commit log]' \
'--no-error[omit error on the commit log]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(verify)
_arguments "${_arguments_options[@]}" \
'-i[Ignore merge commits messages]' \
'--ignore-merge-commits[Ignore merge commits messages]' \
'-h[Print help information]' \
'--help[Print help information]' \
':message -- The commit message:' \
&& ret=0
;;
(changelog)
_arguments "${_arguments_options[@]}" \
'-a+[Generate the changelog for a specific git tag]:AT: ' \
'--at=[Generate the changelog for a specific git tag]:AT: ' \
'-t+[Generate the changelog with the given template. Possible values are '\''remote'\'', '\''full_hash'\'', '\''default'\'' or the path to your template. If not specified cog will use cog.toml template config or fallback to '\''default'\'']:template: ' \
'--template=[Generate the changelog with the given template. Possible values are '\''remote'\'', '\''full_hash'\'', '\''default'\'' or the path to your template. If not specified cog will use cog.toml template config or fallback to '\''default'\'']:template: ' \
'-r+[Url to use during template generation]:remote: ' \
'--remote=[Url to use during template generation]:remote: ' \
'-o+[Repository owner to use during template generation]:owner: ' \
'--owner=[Repository owner to use during template generation]:owner: ' \
'--repository=[Name of the repository used during template generation]:repository: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'::pattern -- Generate the changelog from in the given spec range:' \
&& ret=0
;;
(bump)
_arguments "${_arguments_options[@]}" \
'--version=[Manually set the target version]:VERSION: ' \
'--pre=[Set the pre-release version]:PRE: ' \
'-H+[Specify the bump profile hooks to run]:HOOK_PROFILE: ' \
'--hook-profile=[Specify the bump profile hooks to run]:HOOK_PROFILE: ' \
'-a[Automatically suggest the target version]' \
'--auto[Automatically suggest the target version]' \
'-M[Increment the major version]' \
'--major[Increment the major version]' \
'-m[Increment the minor version]' \
'--minor[Increment the minor version]' \
'-p[Increment the patch version]' \
'--patch[Increment the patch version]' \
'-d[Dry-run : get the target version. No action taken]' \
'--dry-run[Dry-run : get the target version. No action taken]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(init)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
'::path -- path to init:' \
&& ret=0
;;
(install-hook)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':hook-type -- Type of hook to install:(commit-msg pre-push all)' \
&& ret=0
;;
(generate-completions)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':type -- Type of completions to generate:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
        esac
    ;;
esac
}

(( $+functions[_cog_commands] )) ||
_cog_commands() {
    local commands; commands=(
'check:Verify all commit messages against the conventional commit specification' \
'commit:Create a new conventional commit' \
'edit:Interactively rename invalid commit messages' \
'log:Like git log but for conventional commits' \
'verify:Verify a single commit message' \
'changelog:Display a changelog for the given commit oid range' \
'bump:Commit changelog from latest tag to HEAD and create new tag' \
'init:Install cog config files' \
'install-hook:Add git hooks to the repository' \
'generate-completions:Generate shell completions' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'cog commands' commands "$@"
}
(( $+functions[_cog__bump_commands] )) ||
_cog__bump_commands() {
    local commands; commands=()
    _describe -t commands 'cog bump commands' commands "$@"
}
(( $+functions[_cog__changelog_commands] )) ||
_cog__changelog_commands() {
    local commands; commands=()
    _describe -t commands 'cog changelog commands' commands "$@"
}
(( $+functions[_cog__check_commands] )) ||
_cog__check_commands() {
    local commands; commands=()
    _describe -t commands 'cog check commands' commands "$@"
}
(( $+functions[_cog__commit_commands] )) ||
_cog__commit_commands() {
    local commands; commands=()
    _describe -t commands 'cog commit commands' commands "$@"
}
(( $+functions[_cog__edit_commands] )) ||
_cog__edit_commands() {
    local commands; commands=()
    _describe -t commands 'cog edit commands' commands "$@"
}
(( $+functions[_cog__generate-completions_commands] )) ||
_cog__generate-completions_commands() {
    local commands; commands=()
    _describe -t commands 'cog generate-completions commands' commands "$@"
}
(( $+functions[_cog__help_commands] )) ||
_cog__help_commands() {
    local commands; commands=()
    _describe -t commands 'cog help commands' commands "$@"
}
(( $+functions[_cog__init_commands] )) ||
_cog__init_commands() {
    local commands; commands=()
    _describe -t commands 'cog init commands' commands "$@"
}
(( $+functions[_cog__install-hook_commands] )) ||
_cog__install-hook_commands() {
    local commands; commands=()
    _describe -t commands 'cog install-hook commands' commands "$@"
}
(( $+functions[_cog__log_commands] )) ||
_cog__log_commands() {
    local commands; commands=()
    _describe -t commands 'cog log commands' commands "$@"
}
(( $+functions[_cog__verify_commands] )) ||
_cog__verify_commands() {
    local commands; commands=()
    _describe -t commands 'cog verify commands' commands "$@"
}

_cog "$@"
