#compdef dummyhttp

autoload -U is-at-least

_dummyhttp() {
    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[@]}" \
'-p+[Port on which to listen]:PORT: ' \
'--port=[Port on which to listen]:PORT: ' \
'*-H+[Headers to send (format: key:value)]:HEADERS: ' \
'*--headers=[Headers to send (format: key:value)]:HEADERS: ' \
'-c+[HTTP status code to send]:CODE: ' \
'--code=[HTTP status code to send]:CODE: ' \
'-b+[HTTP body to send]:BODY: ' \
'--body=[HTTP body to send]:BODY: ' \
'-i+[Interface to bind to]:INTERFACE: ' \
'--interface=[Interface to bind to]:INTERFACE: ' \
'--print-completions=[Generate completion file for a shell]:shell:(bash elvish fish powershell zsh)' \
'--tls-cert=[TLS certificate to use]:TLS_CERT:_files' \
'--tls-key=[TLS private key to use]:TLS_KEY:_files' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'-q[Be quiet (log nothing)]' \
'--quiet[Be quiet (log nothing)]' \
'*-v[Be verbose (log data of incoming and outgoing requests). If given twice it will also log the body data]' \
'*--verbose[Be verbose (log data of incoming and outgoing requests). If given twice it will also log the body data]' \
'--print-manpage[Generate man page]' \
&& ret=0
}

(( $+functions[_dummyhttp_commands] )) ||
_dummyhttp_commands() {
    local commands; commands=()
    _describe -t commands 'dummyhttp commands' commands "$@"
}

_dummyhttp "$@"
