#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+[]' \
'--config=[]' \
'--config-dir=[]' \
'--chall-dir=[]' \
'--data-dir=[]' \
'--acme-url=[]' \
'--acme-email=[]' \
'*-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[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
":: :_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=[The address to listen on]' \
'--user=[Drop from root to this user]' \
'--chroot[Chroot into the challenge directory]' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
'*-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)]' \
&& ret=0
;;
(status)
_arguments "${_arguments_options[@]}" \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
'*-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)]' \
&& 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]' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
'*-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)]' \
'::certs -- Only renew specific certs:_files' \
&& ret=0
;;
(check)
_arguments "${_arguments_options[@]}" \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
'*-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)]' \
'::certs -- Only check specific certs:_files' \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
'*-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)]' \
':shell:(zsh bash fish powershell elvish)' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
'*-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)]' \
&& ret=0
;;
        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" \
"completions:Generate shell completions" \
"help:Prints 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__help_commands] )) ||
_acme-redirect__help_commands() {
    local commands; commands=(
        
    )
    _describe -t commands 'acme-redirect help 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 "$@"
}

_acme-redirect "$@"