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