#compdef termland-client

autoload -U is-at-least

_termland-client() {
    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[@]}" : \
'*--ssh-opt=[Extra options to pass to the ssh command (repeatable). Example\: --ssh-opt="-oPort=9022" --ssh-opt="-oCompression=yes"]:SSH_OPT:_default' \
'--width=[Requested width]:WIDTH:_default' \
'--height=[Requested height]:HEIGHT:_default' \
'--mode=[Session mode\: "desktop" or "app\:<command>" Examples\: --mode desktop, --mode app\:firefox, --mode "app\:konsole --profile Dark"]:MODE:_default' \
'-q+[Video quality (1-100). Lower values = lower bitrate for slow connections. Default 75. Typical\: 90=high, 75=balanced, 50=low, 25=very low]:QUALITY:_default' \
'--quality=[Video quality (1-100). Lower values = lower bitrate for slow connections. Default 75. Typical\: 90=high, 75=balanced, 50=low, 25=very low]:QUALITY:_default' \
'--desktop-shell=[For --mode desktop\: startup command to run inside labwc. Examples\: "konsole", "startplasma-wayland", "dbus-run-session sway". If omitted, the server auto-detects an available terminal]:DESKTOP_SHELL:_default' \
'--preset=[Override encoder preset. SVT-AV1\: 0..13 (higher = faster, lower latency). QSV\: veryfast|faster|fast|medium|slow|slower|veryslow. NVENC\: p1..p7 (p1 = fastest)]:PRESET:_default' \
'--crf=[Override CRF / quantizer (SVT-AV1 only). 0..63, higher = smaller / lower quality]:CRF:_default' \
'--svt-params=[Extra svtav1-params to append to our low-delay defaults (SVT-AV1 only). Format\: "key=value\:key=value". Example\: "fast-decode=1\:tile-columns=2\:scm=2"]:SVT_PARAMS:_default' \
'-u+[Username for authentication (defaults to current user)]:USER:_default' \
'--user=[Username for authentication (defaults to current user)]:USER:_default' \
'--password=[Password for authentication. WARNING\: visible in /proc/pid/cmdline. Prefer TERMLAND_PASSWORD env var]:PASSWORD:_default' \
'--completions=[Generate shell completion script and exit. Usage\: termland-client --completions fish > ~/.config/fish/completions/termland-client.fish]:SHELL:(bash elvish fish powershell zsh)' \
'--ssh[Use SSH subsystem instead of direct TCP. Runs\: ssh -s <server> termland]' \
'--audio[Enable audio forwarding (Opus over PulseAudio)]' \
'--tls[Connect with TLS encryption]' \
'--accept-invalid-certs[Accept self-signed or invalid TLS certificates (use with --tls)]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::server -- Server address (host\:port for TCP, user@host for SSH):_default' \
&& ret=0
}

(( $+functions[_termland-client_commands] )) ||
_termland-client_commands() {
    local commands; commands=()
    _describe -t commands 'termland-client commands' commands "$@"
}

if [ "$funcstack[1]" = "_termland-client" ]; then
    _termland-client "$@"
else
    compdef _termland-client termland-client
fi
