about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2021-12-02 20:57:49 +0100
committerOliver Kiddle <opk@zsh.org>2021-12-02 21:03:57 +0100
commit9fc0e319c976c4fe72ba113493a25dde26f68f75 (patch)
tree995212e2c1292cd0b33fad29f173a8e08d5bd4ae
parent4775f4dc129d5116892c7738a3e1e9918e6c2e02 (diff)
downloadzsh-9fc0e319c976c4fe72ba113493a25dde26f68f75.tar.gz
zsh-9fc0e319c976c4fe72ba113493a25dde26f68f75.tar.xz
zsh-9fc0e319c976c4fe72ba113493a25dde26f68f75.zip
49631: new logger completion
-rw-r--r--ChangeLog2
-rw-r--r--Completion/Unix/Command/_logger80
2 files changed, 82 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index c67911681..f18fe4e94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2021-12-02  Oliver Kiddle  <opk@zsh.org>
 
+	* 49631: Completion/Unix/Command/_logger: new logger completion
+
 	* 49629: Completion/Linux/Command/_perf: new Linux perf completion
 
 2021-12-01  Daniel Shahaf  <d.s@daniel.shahaf.name>
diff --git a/Completion/Unix/Command/_logger b/Completion/Unix/Command/_logger
new file mode 100644
index 000000000..0d47d2f03
--- /dev/null
+++ b/Completion/Unix/Command/_logger
@@ -0,0 +1,80 @@
+#compdef logger
+
+local variant ign
+local -a args common
+local -a priorities
+
+_pick_variant -r variant linux=util-linux busybox=BusyBox $OSTYPE -V
+
+priorities=( {kern,user,mail,daemon,auth,syslog,lpr,news,uucp,cron,authpriv,ftp,ntp,security,console,local{0..7}}.{emerg,panic,alert,crit,err,error,warn,warning,notice,info,debug} )
+args=( "(--id)-i[log the logger command's pid]" )
+common=(
+  '(-f --file --journald *)'{-f+,--file=}'[log contents of specified file]:file:_files'
+  '(-s --stderr)'{-s,--stderr}'[output message to standard error as well]'
+  '(-P --port)'{-P+,--port}'[use specified port for UDP or TCP connection]:port [514]:_ports'
+  '(-p --priority)'{-p+,--priority}'[mark message with specified priority]:priority:_multi_parts . priorities'
+  '(-t --tag)'{-t+,--tag}"[specify tag to mark log line with]:tag [$USER]"
+)
+
+case $variant in
+  (net|open)bsd*)
+    args+=( ${(M)common:#*\)-[fpst]*}
+      '-c[write the message to the console if unable to use syslogd(8)]'
+    )
+  ;|
+  dragonfly*|freebsd*)
+    args+=(
+      '(-6)-4[use IPv4 addresses only]'
+      '(-4)-6[use IPv6 addresses only]'
+      '-A[send the message to all addresses]'
+    )
+  ;|
+  darwin*|dragonfly*) args+=( ${(M)common:#*\)-[sfpt]*} ) ;|
+  freebsd*)
+    args+=( ${common:#*\)--*}
+      "-H+[set value for hostname in message header]:hostname [${HOST%%.*}]"
+      '-h+[write to specified remote syslog server or socket]: : _alternative
+        "hosts\:server\:_hosts"
+        "sockets\:socket\:_files -g \*\(=\)"'
+      '-S+[specify source address and port when using -h]: :_bind_addresses -0bh'
+    )
+  ;;
+  dragonfly*)
+    args+=( '-h+[write to specified remote syslog server]:server:_hosts' )
+  ;;
+  busybox) args=( ${(M)common:#*\)-[spt]*} ) ;; # no -i
+  solaris*) args+=( ${(M)common:#*\)-[fpt]*} ) ;;
+  netbsd*)
+    args+=(
+      '-d+[log this in the structured data (SD) field]:sd field'
+      '-m+[specify message ID used for the message]:message id'
+      '-n[open log file immediately]'
+    )
+  ;;
+  linux)
+    (( $#words > 2 )) && ign='!'
+    args+=( $common
+      "(-i)--id=-[log the given id, or otherwise the pid]::id [$$]:_pids"
+      '(* -e --skip-empty)'{-e,--skip-empty}"[don't log empty lines when processing files]"
+      '--no-act[do everything except the write the log]'
+      '--octet-count[use rfc6587 octet counting]'
+      '(*)--prio-prefix[look for a prefix on every line read from stdin]'
+      '(-S --size)'{-S+,--size=}'[specify maximum size for a single message]:size [1KiB]'
+      '(-n --server)'{-n+,--server=}'[write to specified remote syslog server]:server:_hosts'
+      '(-T --tcp -d --udp)'{-T,--tcp}'[use TCP only]'
+      '(-d --udp -T --tcp)'{-d,--udp}'[use UDP only]'
+      '(--rfc5424 --msgid --sd-id --sd-param)--rfc3164[use the obsolete BSD syslog protocol]'
+      '(--rfc3164)--rfc5424=-[use the syslog protocol (default for remote)]::without:_sequence compadd - notime notq nohost'
+      '(--rfc3164)*--sd-id=[specify rfc5424 structured data ID]:id'
+      '(--rfc3164)*--sd-param=[specify rfc5424 structured data name=value]:data'
+      '(--rfc3164)--msgid=[set rfc5424 message id field]:message id'
+      '(-u --socket)'{-u,--socket=}'[write to specified Unix socket]:socket:compadd -f -M "r\:|_=* r\:|=*" ${${(M)${(f)"$(</proc/net/unix)"}\:#* /*}##* }'
+      '--socket-errors=-[print connection errors when using Unix sockets]::state:(on off auto)'
+      '(* -f --file)--journald=-[write journald entry]::file:_files'
+      "${ign}(- *)"{-h,--help}'[display usage information]'
+      "${ign}(- *)"{-V,--version}'[display version information]'
+    )
+  ;;
+esac
+
+_arguments -s -S -A "-*" $args '*: :_guard "^-*" message'