#compdef killport

autoload -U is-at-least

_killport() {
    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[@]}" : \
'-m+[Mode of operation\: auto (default, kill both), process (only processes), container (only containers)]: :(auto process container)' \
'--mode=[Mode of operation\: auto (default, kill both), process (only processes), container (only containers)]: :(auto process container)' \
'-s+[SIG is a signal name]:SIG:_default' \
'--signal=[SIG is a signal name]:SIG:_default' \
'--dry-run[Perform a dry run without killing any processes or containers]' \
'--no-fail[Exit successfully even if no matching process or container is found]' \
'*-v[Increase logging verbosity]' \
'*--verbose[Increase logging verbosity]' \
'*-q[Decrease logging verbosity]' \
'*--quiet[Decrease logging verbosity]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::ports -- The list of port numbers to kill processes or containers on:_default' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_killport" ]; then
    _killport "$@"
else
    compdef _killport killport
fi
