#compdef logger local variant local -a args aopts=( -A '-*' ) _pick_variant -r variant util-linux=util-linux $OSTYPE --version case $variant in *) args+=( '(-f -e --file --journald --prio-prefix --skip-empty)*: :_guard "^-*" message' '(: * --journald)'{-f+,--file=}'[log contents of specified file]: :_files' '(--id)-i[log with PID of logger process]' '(-p --priority)'{-p+,--priority=}'[log with specified priority]: :_log_priorities' '(-t --tag)'{-t+,--tag=}'[log with specified tag]:tag' ) ;| darwin*|dragonfly*|freebsd*|linux*|netbsd*|openbsd*) args+=( '(-s --stderr)'{-s,--stderr}'[also log to stderr (LOG_PERROR)]' ) ;| netbsd*|openbsd*) args+=( '-c[log to console if unable to log normally (LOG_CONS)]' ) ;| dragonfly*|freebsd*) args+=( '(-6)-4[log via IPv4 only]' '(-4)-6[log via IPv6 only]' '-A[log to all IP addresses associated with remote host name]' # @todo Complete UNIX-domain sockets '-h+[log to specified remote host or UNIX-domain socket]:remote syslog host:_hosts' ) ;| freebsd*) args+=( '-H+[specify host name for message header]: :_hosts' '-P+[log to specified port (with -h)]:remote syslog port:_ports' # @todo This is another case where we need a dedicated _hosts_ports # function which can properly handle bracketed IPv6 address syntax '-S+[specify source address/port (with -h)]: :_bind_addresses -0bh' ) ;; netbsd*) args+=( '-d+[log specified structured data]:structured data' '-m+[specify RFC5424 MSGID]:MSGID' '-n[open log connection immediately (LOG_NDELAY)]' ) ;; util-linux) aopts=( ) args+=( '(-d -T --tcp --udp)'{-d,--udp}'[log via UDP only (with -n)]' '(: * -e --skip-empty)'{-e,--skip-empty}'[ignore empty lines in input (with -f or stdin)]' '(-i)--id=-[log with PID of logger process or specified PID]:: :_pids' '(--rfc3164)--msgid=[specify RFC5424 MSGID]:MSGID' '(-n --server)'{-n+,--server=}'[log to specified remote host]:remote syslog host:_hosts' '--no-act[do not actually log]' '--octet-count[use RFC6587 octet counting]' '(-P --port)'{-P+,--port=}'[log to specified port (with -n)]:remote syslog port:_ports' '(: *)--prio-prefix[look for priority prefix on each line (with -f or stdin)]' '(--msgid --rfc5424 --sd-id --sd-param)--rfc3164[use RFC3164 BSD syslog protocol]' '(--rfc3164)--rfc5424=-[use RFC5424 syslog protocol with optional exceptions]:protocol exceptions:(( nohost\:"suppress gethostname(2) information" notime\:"suppress complete sender time stamp (implies notq)" notq\:"suppress time-quality structured data" ))' # @todo We could do a better job of completing these next two. The # util-linux man page describes the format and some of the known values. # Also, this is one of those cases where the options have to be given in # order, i.e., each --sd-param must be preceded by --sd-id and vice versa '(--rfc3164)*--sd-id=[specify RFC5424 structured-data element ID]:structured-data element ID' '(--rfc3164)*--sd-param=[specify RFC5424 structured-data element parameter]:structured-data element parameter (name=value)' '--size=[specify maximum message size]:message size (bytes)' '--socket-errors=-[specify socket error-printing behavior]:mode::(auto off on)' '(-u --socket)'{-u+,--socket=}'[write to specified socket instead of default]:syslog socket:_files -g "*(-=D)"' '(-d -T --tcp --udp)'{-t,--tcp}'[log via TCP only (with -n)]' '(: * -)'{-V,--version}'[display version information]' '(: * -)'{-h,--help}'[display help information]' ) # This option actually ignores many other options, like -p (( $+commands[journalctl] )) && args+=( '(: * -f --file)--journald=-[log systemd journal entry from stdin or specified file]: ::_files' ) ;; esac [[ $variant == util-linux ]] || args=( ${args:#(\([^\)]#\)|)(\*|)--*} ) _arguments -s -S $aopts : $args