shell-completions: add systemd-analyze transient-settings

The zsh completions only complete one type argument, even though multiple
args are allowed. But the same issue occurs with other completions, e.g.
for options. I don't know how to solve this.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2025-06-02 20:42:54 +02:00
parent 773cb7aa7e
commit d971936bf4
2 changed files with 16 additions and 0 deletions

View File

@@ -81,6 +81,7 @@ _systemd_analyze() {
[ARCHITECTURES]='architectures'
[FDSTORE]='fdstore'
[CAPABILITY]='capability'
[TRANSIENT_SETTINGS]='transient-settings'
)
local CONFIGS='locale.conf systemd/bootchart.conf systemd/coredump.conf systemd/journald.conf
@@ -225,6 +226,13 @@ _systemd_analyze() {
if [[ $cur = -* ]]; then
comps='--help --version --no-pager --json=off --json=pretty --json=short -m --mask'
fi
elif __contains_word "$verb" ${VERBS[TRANSIENT_SETTINGS]}; then
if [[ $cur = -* ]]; then
comps='--help --version --no-pager'
else
comps="$(systemctl --no-legend --no-pager -t help)"
fi
fi
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )

View File

@@ -47,6 +47,13 @@
_describe 'plot options' _options
}
(( $+functions[_systemd-analyze_transient-settings] )) ||
_systemd-analyze_transient-settings() {
local -a _types
_types=( $(systemctl --no-pager --no-legend -t help) )
_describe -t types 'unit types' _types
}
(( $+functions[_systemd-analyze_commands] )) ||
_systemd-analyze_commands(){
local -a _systemd_analyze_cmds
@@ -74,6 +81,7 @@ JSON or table format'
'security:Analyze security settings of a service'
'inspect-elf:Parse and print ELF package metadata'
'has-tpm2:Report whether TPM2 support is available'
'transient-settings:List transient settings for unit types'
# log-level, log-target, service-watchdogs have been deprecated
)