1
0
mirror of https://github.com/systemd/systemd synced 2024-07-08 20:15:55 +00:00

shell-completion: provide completion for journalctl --namespace=

Resolves: #30381
This commit is contained in:
Frantisek Sumsal 2024-01-05 18:58:43 +01:00
parent 2fe03e25fb
commit 178c8c24ec
2 changed files with 13 additions and 1 deletions

View 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
;;

View 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]' \