]> git.ipfire.org Git - thirdparty/systemd.git/blob - shell-completion/zsh/_systemd-analyze
Merge pull request #8025 from sourcejedi/pid1_journal_or2
[thirdparty/systemd.git] / shell-completion / zsh / _systemd-analyze
1 #compdef systemd-analyze
2 # SPDX-License-Identifier: LGPL-2.1+
3
4 _systemd_analyze_log-level() {
5 local -a _levels
6 _levels=(debug info notice warning err crit alert emerg)
7 _describe -t level 'logging level' _levels || compadd "$@"
8 }
9
10 _systemd_analyze_log-target() {
11 local -a _targets
12 _targets=(console journal kmsg journal-or-kmsg null)
13 _describe -t target 'logging target' _targets || compadd "$@"
14 }
15
16 _systemd_analyze_verify() {
17 _sd_unit_files
18 }
19
20 _systemd_analyze_service-watchdogs() {
21 local -a _states
22 _states=(on off)
23 _describe -t state 'state' _states || compadd "$@"
24 }
25
26 _systemd_analyze_command(){
27 local -a _systemd_analyze_cmds
28 # Descriptions taken from systemd-analyze --help.
29 _systemd_analyze_cmds=(
30 'time:Print time spent in the kernel before reaching userspace'
31 'blame:Print list of running units ordered by time to init'
32 'critical-chain:Print a tree of the time critical chain of units'
33 'plot:Output SVG graphic showing service initialization'
34 'dot:Dump dependency graph (in dot(1) format)'
35 'dump:Dump server status'
36 'log-level:Get/set systemd log threshold'
37 'log-target:Get/set systemd log target'
38 'service-watchdogs:Get/set service watchdog status'
39 'syscall-filter:List syscalls in seccomp filter'
40 'verify:Check unit files for correctness'
41 )
42
43 if (( CURRENT == 1 )); then
44 _describe "options" _systemd_analyze_cmds
45 else
46 local curcontext="$curcontext"
47 cmd="${${_systemd_analyze_cmds[(r)$words[1]:*]%%:*}}"
48 if (( $#cmd )); then
49 if (( $+functions[_systemd_analyze_$cmd] )) && (( CURRENT == 2 )); then
50 _systemd_analyze_$cmd
51 else
52 _message "no more options"
53 fi
54 else
55 _message "unknown systemd-analyze command: $words[1]"
56 fi
57 fi
58 }
59
60 _arguments \
61 {-h,--help}'[Show help text]' \
62 '--version[Show package version]' \
63 '--system[Operate on system systemd instance]' \
64 '--user[Operate on user systemd instance]' \
65 '--no-pager[Do not pipe output into a pager]' \
66 '--man=[Do (not) check for existence of man pages]:boolean:(1 0)' \
67 '--order[When generating graph for dot, show only order]' \
68 '--require[When generating graph for dot, show only requirement]' \
69 '--fuzz=[When printing the tree of the critical chain, print also services, which finished TIMESPAN earlier, than the latest in the branch]:TIMESPAN' \
70 '--from-pattern=[When generating a dependency graph, filter only origins]:GLOB' \
71 '--to-pattern=[When generating a dependency graph, filter only destinations]:GLOB' \
72 {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \
73 {-M+,--machine=}'[Operate on local container]:machine:_sd_machines' \
74 '*::systemd-analyze commands:_systemd_analyze_command'