#compdef iftoprs

autoload -U is-at-least

_iftoprs() {
    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+[Path to config file (default\: ~/.iftoprs.conf)]:CONFIG:_default' \
'--config=[Path to config file (default\: ~/.iftoprs.conf)]:CONFIG:_default' \
'-i+[Network interface to monitor]:INTERFACE:_default' \
'--interface=[Network interface to monitor]:INTERFACE:_default' \
'-f+[BPF filter expression (e.g., "tcp port 80")]:FILTER:_default' \
'--filter=[BPF filter expression (e.g., "tcp port 80")]:FILTER:_default' \
'-F+[IPv4 network filter (e.g., "192.168.1.0/24")]:NET_FILTER:_default' \
'--net-filter=[IPv4 network filter (e.g., "192.168.1.0/24")]:NET_FILTER:_default' \
'--completions=[Generate shell completions (bash, zsh, fish, elvish, powershell)]:SHELL:(bash elvish fish powershell zsh)' \
'-n[Disable DNS hostname resolution]' \
'--no-dns[Disable DNS hostname resolution]' \
'-N[Disable port-to-service resolution]' \
'--no-port-names[Disable port-to-service resolution]' \
'-p[Enable promiscuous mode]' \
'--promiscuous[Enable promiscuous mode]' \
'-b[Disable bar graph display]' \
'--no-bars[Disable bar graph display]' \
'-B[Display bandwidth in bytes (instead of bits)]' \
'--bytes[Display bandwidth in bytes (instead of bits)]' \
'-P[Hide ports alongside hosts]' \
'--hide-ports[Hide ports alongside hosts]' \
'-Z[Hide owning process column]' \
'--no-processes[Hide owning process column]' \
'-l[List available interfaces and exit]' \
'--list-interfaces[List available interfaces and exit]' \
'--json[Stream flow data as newline-delimited JSON (no TUI)]' \
'--list-colors[Preview all color themes and exit]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_iftoprs" ]; then
    _iftoprs "$@"
else
    compdef _iftoprs iftoprs
fi
