#compdef rustnet

autoload -U is-at-least

_rustnet() {
    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[@]}" : \
'-i+[Network interface to monitor (use "any" to capture all interfaces)]:INTERFACE:_default' \
'--interface=[Network interface to monitor (use "any" to capture all interfaces)]:INTERFACE:_default' \
'-r+[UI refresh interval in milliseconds]:MILLISECONDS:_default' \
'--refresh-interval=[UI refresh interval in milliseconds]:MILLISECONDS:_default' \
'-l+[Set the log level (if not provided, no logging will be enabled)]:LEVEL:_default' \
'--log-level=[Set the log level (if not provided, no logging will be enabled)]:LEVEL:_default' \
'--json-log=[Enable JSON logging of connection events to specified file]:FILE:_default' \
'--pcap-export=[Export captured packets to PCAP file for Wireshark analysis]:FILE:_default' \
'-f+[BPF filter expression for packet capture (e.g., "tcp port 443", "dst port 80")]:FILTER:_default' \
'--bpf-filter=[BPF filter expression for packet capture (e.g., "tcp port 443", "dst port 80")]:FILTER:_default' \
'--theme=[Color theme preset\: "muted" (single accent, color reserved for signals) or "classic" (original full-color palette)]:PRESET:(muted classic)' \
'--geoip-country=[Path to GeoLite2-Country.mmdb database. Auto-discovered from\: ./resources/geoip2, \$XDG_DATA_HOME/rustnet/geoip, ~/.local/share/rustnet/geoip, /usr/share/GeoIP, /usr/local/share/GeoIP, /opt/homebrew/share/GeoIP, /var/lib/GeoIP]:PATH:_default' \
'--geoip-asn=[Path to GeoLite2-ASN.mmdb database (same search paths as --geoip-country)]:PATH:_default' \
'--geoip-city=[Path to GeoLite2-City.mmdb database (same search paths as --geoip-country; superset of Country — provides city name and postal code in addition to country)]:PATH:_default' \
'--no-localhost[Filter out localhost connections]' \
'--show-localhost[Show localhost connections (overrides default filtering)]' \
'--no-dpi[Disable deep packet inspection]' \
'--no-resolve-dns[Disable reverse DNS resolution for IP addresses (enabled by default; shows hostnames instead of IPs)]' \
'--show-ptr-lookups[Show PTR lookup connections in UI (hidden by default when DNS resolution is enabled)]' \
'--no-color[Disable all colors in the UI (also respects NO_COLOR env var)]' \
'--no-geoip[Disable GeoIP lookups entirely]' \
'--no-sandbox[Disable sandboxing (on Linux, PR_SET_NO_NEW_PRIVS is still set)]' \
'(--no-sandbox)--sandbox-strict[Require full sandbox enforcement or exit]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_rustnet" ]; then
    _rustnet "$@"
else
    compdef _rustnet rustnet
fi
