#compdef acme-redirect

autoload -U is-at-least

_acme-redirect() {
    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:_default' \
'--config=[]:path:_default' \
'--config-dir=[]:path:_default' \
'--chall-dir=[]:path:_default' \
'--data-dir=[]:path:_default' \
'--acme-url=[]:ACME_URL:_default' \
'--acme-email=[]:ACME_EMAIL:_default' \
'*-v[Verbose logging output (Can be set multiple times)]' \
'*--verbose[Verbose logging output (Can be set multiple times)]' \
'-q[Silent output (except errors)]' \
'--quiet[Silent output (except errors)]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_acme-redirect_commands" \
"*::: :->acme-redirect" \
&& ret=0
    case $state in
    (acme-redirect)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:acme-redirect-command-$line[1]:"
        case $line[1] in
            (daemon)
_arguments "${_arguments_options[@]}" : \
'-B+[The address to listen on]:BIND_ADDR:_default' \
'--bind-addr=[The address to listen on]:BIND_ADDR:_default' \
'--user=[Drop from root to this user]:USER:_default' \
'--chroot[Chroot into the challenge directory]' \
'*-v[Verbose logging output (Can be set multiple times)]' \
'*--verbose[Verbose logging output (Can be set multiple times)]' \
'-q[Silent output (except errors)]' \
'--quiet[Silent output (except errors)]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(status)
_arguments "${_arguments_options[@]}" : \
'*-v[Verbose logging output (Can be set multiple times)]' \
'*--verbose[Verbose logging output (Can be set multiple times)]' \
'-q[Silent output (except errors)]' \
'--quiet[Silent output (except errors)]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(renew)
_arguments "${_arguments_options[@]}" : \
'-n[Do not actually do anything, just show what would happen]' \
'--dry-run[Do not actually do anything, just show what would happen]' \
'--force-renew[Renew certificates even if they are not about to expire]' \
'--skip-restarts[Do not execute the configured exec commands]' \
'--skip-cleanup[Don'\''t clean up old certs that are not live anymore]' \
'--hooks-only[Only execute hooks without actually renewing certs]' \
'*-v[Verbose logging output (Can be set multiple times)]' \
'*--verbose[Verbose logging output (Can be set multiple times)]' \
'-q[Silent output (except errors)]' \
'--quiet[Silent output (except errors)]' \
'-h[Print help]' \
'--help[Print help]' \
'*::certs -- Only renew specific certs:_default' \
&& ret=0
;;
(check)
_arguments "${_arguments_options[@]}" : \
'*-v[Verbose logging output (Can be set multiple times)]' \
'*--verbose[Verbose logging output (Can be set multiple times)]' \
'-q[Silent output (except errors)]' \
'--quiet[Silent output (except errors)]' \
'-h[Print help]' \
'--help[Print help]' \
'*::certs -- Only check specific certs:_default' \
&& ret=0
;;
(dump-config)
_arguments "${_arguments_options[@]}" : \
'*-v[Verbose logging output (Can be set multiple times)]' \
'*--verbose[Verbose logging output (Can be set multiple times)]' \
'-q[Silent output (except errors)]' \
'--quiet[Silent output (except errors)]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
'*-v[Verbose logging output (Can be set multiple times)]' \
'*--verbose[Verbose logging output (Can be set multiple times)]' \
'-q[Silent output (except errors)]' \
'--quiet[Silent output (except errors)]' \
'-h[Print help]' \
'--help[Print help]' \
':shell:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_acme-redirect__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:acme-redirect-help-command-$line[1]:"
        case $line[1] in
            (daemon)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(status)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(renew)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(check)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(dump-config)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_acme-redirect_commands] )) ||
_acme-redirect_commands() {
    local commands; commands=(
'daemon:Run the redirect daemon' \
'status:Show the status of our certificates' \
'renew:Request new certificates if needed' \
'check:Check if the challenges could be completed' \
'dump-config:Load the configuration and dump it to stdout as json' \
'completions:Generate shell completions' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'acme-redirect commands' commands "$@"
}
(( $+functions[_acme-redirect__check_commands] )) ||
_acme-redirect__check_commands() {
    local commands; commands=()
    _describe -t commands 'acme-redirect check commands' commands "$@"
}
(( $+functions[_acme-redirect__completions_commands] )) ||
_acme-redirect__completions_commands() {
    local commands; commands=()
    _describe -t commands 'acme-redirect completions commands' commands "$@"
}
(( $+functions[_acme-redirect__daemon_commands] )) ||
_acme-redirect__daemon_commands() {
    local commands; commands=()
    _describe -t commands 'acme-redirect daemon commands' commands "$@"
}
(( $+functions[_acme-redirect__dump-config_commands] )) ||
_acme-redirect__dump-config_commands() {
    local commands; commands=()
    _describe -t commands 'acme-redirect dump-config commands' commands "$@"
}
(( $+functions[_acme-redirect__help_commands] )) ||
_acme-redirect__help_commands() {
    local commands; commands=(
'daemon:Run the redirect daemon' \
'status:Show the status of our certificates' \
'renew:Request new certificates if needed' \
'check:Check if the challenges could be completed' \
'dump-config:Load the configuration and dump it to stdout as json' \
'completions:Generate shell completions' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'acme-redirect help commands' commands "$@"
}
(( $+functions[_acme-redirect__help__check_commands] )) ||
_acme-redirect__help__check_commands() {
    local commands; commands=()
    _describe -t commands 'acme-redirect help check commands' commands "$@"
}
(( $+functions[_acme-redirect__help__completions_commands] )) ||
_acme-redirect__help__completions_commands() {
    local commands; commands=()
    _describe -t commands 'acme-redirect help completions commands' commands "$@"
}
(( $+functions[_acme-redirect__help__daemon_commands] )) ||
_acme-redirect__help__daemon_commands() {
    local commands; commands=()
    _describe -t commands 'acme-redirect help daemon commands' commands "$@"
}
(( $+functions[_acme-redirect__help__dump-config_commands] )) ||
_acme-redirect__help__dump-config_commands() {
    local commands; commands=()
    _describe -t commands 'acme-redirect help dump-config commands' commands "$@"
}
(( $+functions[_acme-redirect__help__help_commands] )) ||
_acme-redirect__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'acme-redirect help help commands' commands "$@"
}
(( $+functions[_acme-redirect__help__renew_commands] )) ||
_acme-redirect__help__renew_commands() {
    local commands; commands=()
    _describe -t commands 'acme-redirect help renew commands' commands "$@"
}
(( $+functions[_acme-redirect__help__status_commands] )) ||
_acme-redirect__help__status_commands() {
    local commands; commands=()
    _describe -t commands 'acme-redirect help status commands' commands "$@"
}
(( $+functions[_acme-redirect__renew_commands] )) ||
_acme-redirect__renew_commands() {
    local commands; commands=()
    _describe -t commands 'acme-redirect renew commands' commands "$@"
}
(( $+functions[_acme-redirect__status_commands] )) ||
_acme-redirect__status_commands() {
    local commands; commands=()
    _describe -t commands 'acme-redirect status commands' commands "$@"
}

if [ "$funcstack[1]" = "_acme-redirect" ]; then
    _acme-redirect "$@"
else
    compdef _acme-redirect acme-redirect
fi
