From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 6170 invoked from network); 2 Dec 2021 19:54:22 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 2 Dec 2021 19:54:22 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:To:From:Reply-To:Cc: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=fCpE2NFPjgTez3nFKYQF/PSRmcI+YM9hcWAIyVrqYps=; b=ZdST8sQXk5TcDr97qBNNUgwttk OasjnZlS65y8mssJMbqqgFL9QyhVzZUSYlXzlYZ8hb5uY+PUzZFuvOcYiZPI2fUMqy2Dao8O0vV1F lF0cE+Ld9CDNeOhxCR+kwfsNDmNJvKckY06x7z5bZg29rlnyDiKVRzhMkVabFHOT33ZEkQzvNUDIs cCGVid4a9p4oGxOLaaTcDI4EiVMMlVQj9mz+5AMQ7itHAO0t/jqlWG8hjvKW7+msL4l3iJstGajNR ShPLga2LdExSALoEh5oPBT7v/VMoVMl0ylR7mGNJX9C7HJ9baD4vlJRNb+kSBmHtUl4GGNjMIuALL xnevwsqA==; Received: from authenticated user by zero.zsh.org with local id 1mss9t-000KUv-Rr; Thu, 02 Dec 2021 19:54:21 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mss9a-000KCt-Mt; Thu, 02 Dec 2021 19:54:02 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.94.2) (envelope-from ) id 1mss9Z-000HS2-KM for zsh-workers@zsh.org; Thu, 02 Dec 2021 20:54:01 +0100 From: Oliver Kiddle To: Zsh workers Subject: PATCH: new logger completion MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <67084.1638474841.1@hydra> Date: Thu, 02 Dec 2021 20:54:01 +0100 Message-ID: <67085-1638474841.627924@nMcq.VXhZ.xyz-> X-Seq: 49631 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: This is another of the few remaining util-linux utilities for which we didn't have a completion. It also handles the busybox implementation because I tried (and failed) to persuade an OpenWRT access point to send it's log messages elsewhere over the network. Oliver diff --git a/_logger b/_logger new file mode 100644 index 000000000..0d47d2f03 --- /dev/null +++ b/_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)"$(