#compdef prr

autoload -U is-at-least

_prr() {
    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[@]}" : \
'--config=[Path to config file]:CONFIG:_files' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_prr_commands" \
"*::: :->prr" \
&& ret=0
    case $state in
    (prr)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:prr-command-$line[1]:"
        case $line[1] in
            (get)
_arguments "${_arguments_options[@]}" : \
'-f[Ignore unsubmitted review checks]' \
'--force[Ignore unsubmitted review checks]' \
'--open[Open review file in \$EDITOR after download]' \
'-h[Print help]' \
'--help[Print help]' \
':pr -- Pull request to review (eg. `danobi/prr/24`):_default' \
&& ret=0
;;
(edit)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':pr -- Pull request to edit (eg. `danobi/prr/24`):_default' \
&& ret=0
;;
(submit)
_arguments "${_arguments_options[@]}" : \
'-d[]' \
'--debug[]' \
'-h[Print help]' \
'--help[Print help]' \
':pr -- Pull request to review (eg. `danobi/prr/24`):_default' \
&& ret=0
;;
(apply)
_arguments "${_arguments_options[@]}" : \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':pr:_default' \
&& ret=0
;;
(status)
_arguments "${_arguments_options[@]}" : \
'-n[Hide column titles from output]' \
'--no-titles[Hide column titles from output]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(remove)
_arguments "${_arguments_options[@]}" : \
'-f[Ignore unsubmitted review checks]' \
'--force[Ignore unsubmitted review checks]' \
'-s[Remove submitted reviews in addition to provided reviews]' \
'--submitted[Remove submitted reviews in addition to provided reviews]' \
'-h[Print help]' \
'--help[Print help]' \
'*::prs -- Pull requests to remove (eg. `danobi/prr/24`):_default' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_prr__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:prr-help-command-$line[1]:"
        case $line[1] in
            (get)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(edit)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(submit)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(apply)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(status)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(remove)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_prr_commands] )) ||
_prr_commands() {
    local commands; commands=(
'get:Get a pull request and begin a review' \
'edit:Open an existing review in \$EDITOR' \
'submit:Submit a review' \
'apply:Apply a pull request to the working directory' \
'status:Print a status summary of all known reviews' \
'remove:Remove a review' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'prr commands' commands "$@"
}
(( $+functions[_prr__apply_commands] )) ||
_prr__apply_commands() {
    local commands; commands=()
    _describe -t commands 'prr apply commands' commands "$@"
}
(( $+functions[_prr__edit_commands] )) ||
_prr__edit_commands() {
    local commands; commands=()
    _describe -t commands 'prr edit commands' commands "$@"
}
(( $+functions[_prr__get_commands] )) ||
_prr__get_commands() {
    local commands; commands=()
    _describe -t commands 'prr get commands' commands "$@"
}
(( $+functions[_prr__help_commands] )) ||
_prr__help_commands() {
    local commands; commands=(
'get:Get a pull request and begin a review' \
'edit:Open an existing review in \$EDITOR' \
'submit:Submit a review' \
'apply:Apply a pull request to the working directory' \
'status:Print a status summary of all known reviews' \
'remove:Remove a review' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'prr help commands' commands "$@"
}
(( $+functions[_prr__help__apply_commands] )) ||
_prr__help__apply_commands() {
    local commands; commands=()
    _describe -t commands 'prr help apply commands' commands "$@"
}
(( $+functions[_prr__help__edit_commands] )) ||
_prr__help__edit_commands() {
    local commands; commands=()
    _describe -t commands 'prr help edit commands' commands "$@"
}
(( $+functions[_prr__help__get_commands] )) ||
_prr__help__get_commands() {
    local commands; commands=()
    _describe -t commands 'prr help get commands' commands "$@"
}
(( $+functions[_prr__help__help_commands] )) ||
_prr__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'prr help help commands' commands "$@"
}
(( $+functions[_prr__help__remove_commands] )) ||
_prr__help__remove_commands() {
    local commands; commands=()
    _describe -t commands 'prr help remove commands' commands "$@"
}
(( $+functions[_prr__help__status_commands] )) ||
_prr__help__status_commands() {
    local commands; commands=()
    _describe -t commands 'prr help status commands' commands "$@"
}
(( $+functions[_prr__help__submit_commands] )) ||
_prr__help__submit_commands() {
    local commands; commands=()
    _describe -t commands 'prr help submit commands' commands "$@"
}
(( $+functions[_prr__remove_commands] )) ||
_prr__remove_commands() {
    local commands; commands=()
    _describe -t commands 'prr remove commands' commands "$@"
}
(( $+functions[_prr__status_commands] )) ||
_prr__status_commands() {
    local commands; commands=()
    _describe -t commands 'prr status commands' commands "$@"
}
(( $+functions[_prr__submit_commands] )) ||
_prr__submit_commands() {
    local commands; commands=()
    _describe -t commands 'prr submit commands' commands "$@"
}

if [ "$funcstack[1]" = "_prr" ]; then
    _prr "$@"
else
    compdef _prr prr
fi
