]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shell-completion: add journalctl --facility
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 24 Nov 2021 10:21:10 +0000 (11:21 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 24 Nov 2021 12:44:34 +0000 (12:44 +0000)
Fixes #21484.

shell-completion/bash/journalctl
shell-completion/zsh/_journalctl

index 84232e83c2bad5db7a563031b4a986ca1be689fd..9a55c2d62d7a8ba2273f3c945eaaab5924722745 100644 (file)
@@ -32,6 +32,7 @@ __get_machines() {
 }
 
 __syslog_priorities=(emerg alert crit err warning notice info debug)
+__syslog_facilities=(kern user mail daemon auth syslog lpr news uucp cron authpriv ftp local0 local1 local2 local3 local4 local5 local6 local7)
 
 _journalctl() {
     local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
@@ -44,7 +45,7 @@ _journalctl() {
                       --show-cursor --dmesg -k --pager-end -e -r --reverse
                       --utc -x --catalog --no-full --force --dump-catalog
                       --flush --rotate --sync --no-hostname -N --fields'
-        [ARG]='-b --boot -D --directory --file -F --field -t --identifier
+        [ARG]='-b --boot -D --directory --file -F --field -t --identifier --facility
                       -M --machine -o --output -u --unit --user-unit -p --priority
                       --root --case-sensitive'
         [ARGUNKNOWN]='-c --cursor --interval -n --lines -S --since -U --until
@@ -81,6 +82,9 @@ _journalctl() {
             --machine|-M)
                 comps=$( __get_machines )
                 ;;
+            --facility)
+                comps=${__syslog_facilities[*]}
+                ;;
             --priority|-p)
                 comps=${__syslog_priorities[*]}
                 compopt -o nosort
index 90d7579cce5c46006525396879070cf0ea82d065..5dba1e7dfe1745d8ea8a98d89bf55809d0077b36 100644 (file)
@@ -56,6 +56,13 @@ _journalctl_boots() {
     "bootid:boot ids:compadd -a _bootid"
 }
 
+(( $+functions[_journalctl_facilities] )) ||
+_journalctl_facilities() {
+  local -a _journalctl_facilities
+  _journalctl_facilities=(kern user mail daemon auth syslog lpr news uucp cron authpriv ftp local0 local1 local2 local3 local4 local5 local6 local7)
+  _describe 'possible values' _journalctl_facilities
+}
+
 # Build arguments for "journalctl" to be used in completion.
 # Use both --user and --system modes, they are not exclusive.
 local -a _modes; _modes=(--user --system)
@@ -103,7 +110,8 @@ _arguments -s \
     {-u+,--unit=}'[Show data only from the specified unit]:units:_journalctl_field_values _SYSTEMD_UNIT' \
     '--user-unit=[Show data only from the specified user session unit]:units:_journalctl_field_values USER_UNIT' \
     {-p+,--priority=}'[Show only messages within the specified priority range]:priority:_journalctl_field_values PRIORITY' \
-    {-t+,--identifier=}'[Show only messages with the specified syslog identifier]:identifier:_journalctl_field_values SYSLOG_IDENTIFIER' \
+    '--facility=[Filter messages by facility]:facility:_journalctl_facilities' \
+    {-t+,--identifier=}'[Filter messages by syslog identifier]:identifier:_journalctl_field_values SYSLOG_IDENTIFIER' \
     {-c+,--cursor=}'[Start showing entries from the specified cursor]:cursors:_journalctl_field_values __CURSORS' \
     '--cursor-file=[Show entries using cursor store in file]:file:_files' \
     '--after-cursor=[Start showing entries from after the specified cursor]:cursors:_journalctl_field_values __CURSORS' \