]> git.ipfire.org Git - thirdparty/systemd.git/blame - shell-completion/zsh/_systemd-analyze
license: LGPL-2.1+ -> LGPL-2.1-or-later
[thirdparty/systemd.git] / shell-completion / zsh / _systemd-analyze
CommitLineData
c1072f64 1#compdef systemd-analyze -*- shell-script -*-
db9ecf05 2# SPDX-License-Identifier: LGPL-2.1-or-later
7abfbe79 3
c501ecd7 4(( $+functions[_systemd-analyze_log-level] )) ||
843cfcb1
ZJS
5 _systemd-analyze_log-level() {
6 local -a _levels
7 _levels=(debug info notice warning err crit alert emerg)
8 _describe -t level 'logging level' _levels || compadd "$@"
9 }
fe05567c 10
c501ecd7 11(( $+functions[_systemd-analyze_log-target] )) ||
843cfcb1
ZJS
12 _systemd-analyze_log-target() {
13 local -a _targets
14 _targets=(console journal kmsg journal-or-kmsg null)
15 _describe -t target 'logging target' _targets || compadd "$@"
16 }
4146ac2a 17
c501ecd7 18(( $+functions[_systemd-analyze_verify] )) ||
843cfcb1
ZJS
19 _systemd-analyze_verify() {
20 _sd_unit_files
21 }
2c12a402 22
c501ecd7 23(( $+functions[_systemd-analyze_service-watchdogs] )) ||
843cfcb1
ZJS
24 _systemd-analyze_service-watchdogs() {
25 local -a _states
26 _states=(on off)
27 _describe -t state 'state' _states || compadd "$@"
28 }
dba081db 29
4b6d94a1
RP
30(( $+functions[_systemd-analyze_cat-config] )) ||
31 _systemd-analyze_cat-config() {
32 _files -W '(/run/systemd/ /etc/systemd/ /usr/lib/systemd/)' -P 'systemd/'
33 }
34
35(( $+functions[_systemd-analyze_security] )) ||
36 _systemd-analyze_security() {
37 _sd_unit_files
38 }
39
c501ecd7 40(( $+functions[_systemd-analyze_commands] )) ||
843cfcb1
ZJS
41 _systemd-analyze_commands(){
42 local -a _systemd_analyze_cmds
43 # Descriptions taken from systemd-analyze --help.
44 _systemd_analyze_cmds=(
45 'time:Print time spent in the kernel before reaching userspace'
46 'blame:Print list of running units ordered by time to init'
47 'critical-chain:Print a tree of the time critical chain of units'
48 'plot:Output SVG graphic showing service initialization'
49 'dot:Dump dependency graph (in dot(1) format)'
50 'dump:Dump server status'
4b6d94a1
RP
51 'cat-config:Cat systemd config files'
52 'unit-files:List files and symlinks for units'
843cfcb1 53 'unit-paths:List unit load paths'
4b6d94a1 54 'exit-status:List known exit statuses'
843cfcb1 55 'syscall-filter:List syscalls in seccomp filter'
4b6d94a1 56 'condition:Evaluate Condition*= and Assert*= assignments'
843cfcb1
ZJS
57 'verify:Check unit files for correctness'
58 'calendar:Validate repetitive calendar time events'
4b6d94a1
RP
59 'timestamp:Parse a systemd syntax timestamp'
60 'timespan:Parse a systemd syntax timespan'
61 'security:Analyze security settings of a service'
62 # 'log-level:Get/set systemd log threshold'
63 # 'log-target:Get/set systemd log target'
64 # 'service-watchdogs:Get/set service watchdog status'
843cfcb1 65 )
7abfbe79 66
843cfcb1
ZJS
67 if (( CURRENT == 1 )); then
68 _describe "options" _systemd_analyze_cmds
69 else
70 local curcontext="$curcontext"
71 cmd="${${_systemd_analyze_cmds[(r)$words[1]:*]%%:*}}"
72 if (( $#cmd )); then
73 if (( $+functions[_systemd-analyze_$cmd] )) && (( CURRENT == 2 )); then
74 _systemd-analyze_$cmd
75 else
76 _message "no more options"
77 fi
fe05567c 78 else
843cfcb1 79 _message "unknown systemd-analyze command: $words[1]"
fe05567c 80 fi
fe05567c 81 fi
843cfcb1 82 }
7abfbe79
WG
83
84_arguments \
26bd71f0
RC
85 {-h,--help}'[Show help text]' \
86 '--version[Show package version]' \
87 '--system[Operate on system systemd instance]' \
88 '--user[Operate on user systemd instance]' \
ecd3717a 89 '--global[Show global user instance config]' \
26bd71f0 90 '--no-pager[Do not pipe output into a pager]' \
cc98b302 91 '--man=[Do (not) check for existence of man pages]:boolean:(1 0)' \
7abfbe79
WG
92 '--order[When generating graph for dot, show only order]' \
93 '--require[When generating graph for dot, show only requirement]' \
26bd71f0
RC
94 '--fuzz=[When printing the tree of the critical chain, print also services, which finished TIMESPAN earlier, than the latest in the branch]:TIMESPAN' \
95 '--from-pattern=[When generating a dependency graph, filter only origins]:GLOB' \
96 '--to-pattern=[When generating a dependency graph, filter only destinations]:GLOB' \
2c12a402 97 {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \
b93f15cd 98 {-M+,--machine=}'[Operate on local container]:machine:_sd_machines' \
c501ecd7 99 '*::systemd-analyze commands:_systemd-analyze_commands'