]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shell-completion: provide completion for journalctl --namespace= 30796/head
authorFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 5 Jan 2024 17:58:43 +0000 (18:58 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 5 Jan 2024 18:21:51 +0000 (19:21 +0100)
Resolves: #30381

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

index 22d9eb2cfc11b05599da932509ddd45031ae4ab9..c7f6a05a6efa8c7c1ded1d56213a6c132789f8e2 100644 (file)
@@ -49,7 +49,8 @@ _journalctl() {
                       --list-namespaces'
         [ARG]='-b --boot -D --directory --file -F --field -t --identifier
                       -T --exclude-identifier --facility -M --machine -o --output
-                      -u --unit --user-unit -p --priority --root --case-sensitive'
+                      -u --unit --user-unit -p --priority --root --case-sensitive
+                      --namespace'
         [ARGUNKNOWN]='-c --cursor --interval -n --lines -S --since -U --until
                       --after-cursor --cursor-file --verify-key -g --grep
                       --vacuum-size --vacuum-time --vacuum-files --output-fields'
@@ -114,6 +115,9 @@ _journalctl() {
             --case-sensitive)
                 comps='yes no'
                 ;;
+            --namespace)
+                comps=$(journalctl --list-namespaces --output=cat 2>/dev/null)
+                ;;
             *)
                 return 0
                 ;;
index 7e18d431584e37f50b17ddbdbcfc01f48dc1457a..9c132b8731cf2d3884ce2d61be85cfd788468e47 100644 (file)
@@ -63,6 +63,13 @@ _journalctl_facilities() {
   _describe 'possible values' _journalctl_facilities
 }
 
+(( $+functions[_journalctl_namespaces] )) ||
+_journalctl_namespaces() {
+  local -a _journalctl_namespaces
+  _journalctl_namespaces=( ${(f)"$(_call_program namespaces "$service --list-namespaces --output=cat" 2>/dev/null)"} )
+  _describe 'possible values' _journalctl_namespaces
+}
+
 # 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)
@@ -132,6 +139,7 @@ _arguments -s \
     '--interval=[Time interval for changing the FSS sealing key]:time interval' \
     '--list-catalog[List messages in catalog]' \
     '--list-namespaces[List available journal namespaces]' \
+    '--namespace[Show journal data from specified namespace]:namespace:_journalctl_namespaces' \
     '--new-id128[Generate a new 128 Bit ID]' \
     '--rotate[Request immediate rotation of the journal files]' \
     '--setup-keys[Generate a new FSS key pair]' \