#compdef ttl

autoload -U is-at-least

_ttl() {
    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+[Number of probe rounds (0 = infinite). Each round sends probes to all TTLs]:COUNT:_default' \
'--count=[Number of probe rounds (0 = infinite). Each round sends probes to all TTLs]:COUNT:_default' \
'-i+[Probe interval in seconds]:INTERVAL:_default' \
'--interval=[Probe interval in seconds]:INTERVAL:_default' \
'-m+[Maximum TTL (hops)]:MAX_TTL:_default' \
'--max-ttl=[Maximum TTL (hops)]:MAX_TTL:_default' \
'-p+[Probe protocol (auto, icmp, udp, tcp)]:PROTOCOL:_default' \
'--protocol=[Probe protocol (auto, icmp, udp, tcp)]:PROTOCOL:_default' \
'--port=[Port for UDP/TCP probes]:PORT:_default' \
'--flows=[Number of flows for multi-path ECMP detection (1 = classic mode)]:FLOWS:_default' \
'--src-port=[Base source port for flow identification]:SRC_PORT:_default' \
'--timeout=[Probe timeout in seconds]:TIMEOUT:_default' \
'--geoip-db=[Path to MaxMind GeoLite2 database file]:GEOIP_DB:_default' \
'--replay=[Replay a saved session]:REPLAY:_default' \
'--speed=[Replay speed multiplier (1.0 = realtime, 10.0 = 10x faster)]:SPEED:_default' \
'--theme=[Color theme (default, kawaii, cyber, dracula, monochrome, matrix, nord, gruvbox, catppuccin, tokyo_night, solarized)]:THEME:_default' \
'--interface=[Bind probes to specific network interface (e.g., eth0, wlan0)]:INTERFACE:_default' \
'--dscp=[DSCP value for QoS testing (0-63)]:DSCP:_default' \
'(--pmtud)--size=[Probe packet size in bytes (36-9216 for IPv4, 56-9216 for IPv6) Includes IP + protocol headers. Smaller values are clamped to minimum. Supports jumbo frames up to 9216 bytes]:SIZE:_default' \
'--rate=[Maximum probes per second (0 = unlimited)]:RATE:_default' \
'--source-ip=[Source IP address for probes]:IP:_default' \
'--completions=[Generate shell completions and exit]:SHELL:(bash zsh fish powershell)' \
'--fixed-port[Use fixed port (disable per-TTL port variation)]' \
'-4[Force IPv4]' \
'--ipv4[Force IPv4]' \
'-6[Force IPv6]' \
'--ipv6[Force IPv6]' \
'--resolve-all[Trace all resolved IP addresses for hostnames (round-robin DNS, dual-stack)]' \
'--no-dns[Skip reverse DNS lookups]' \
'--no-asn[Skip ASN enrichment]' \
'--no-geo[Skip geolocation]' \
'--no-ix[Skip IX detection (PeeringDB)]' \
'--no-tui[Disable TUI (streaming output mode)]' \
'--json[Output JSON (batch mode, requires -c)]' \
'--csv[Output CSV (batch mode, requires -c)]' \
'--report[Report mode (batch, requires -c)]' \
'--animate[Animate replay showing probe-by-probe discovery]' \
'--wide[Wide mode\: expand columns for wider terminals]' \
'--recv-any[Don'\''t bind receiver socket to interface (allows asymmetric routing)]' \
'--pmtud[Enable Path MTU discovery mode (binary search for max unfragmented size)]' \
'--jumbo[Enable jumbo frame detection (9216 byte max) for PMTUD Without this flag, PMTUD uses standard ethernet max (1500 bytes)]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::targets -- Target hosts to trace (IP address or hostname):_default' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_ttl" ]; then
    _ttl "$@"
else
    compdef _ttl ttl
fi
