chiark / gitweb /
shell-completions: systemd-analyze set-log-level
[elogind.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_command(){
10     local -a _systemd_analyze_cmds
11     # Descriptions taken from systemd-analyze --help.
12     _systemd_analyze_cmds=(
13         'time:Print time spent in the kernel before reaching userspace'
14         'blame:Print list of running units ordered by time to init'
15         'critical-chain:Print a tree of the time critical chain of units'
16         'plot:Output SVG graphic showing service initialization'
17         'dot:Dump dependency graph (in dot(1) format)'
18         'set-log-level:Set systemd log threshold'
19     )
20
21     if (( CURRENT == 1 )); then
22         _describe "options" _systemd_analyze_cmds
23     else
24         local curcontext="$curcontext"
25         cmd="${${_systemd_analyze_cmds[(r)$words[1]:*]%%:*}}"
26         if (( $#cmd )); then
27             if (( $+functions[_systemd_analyze_$cmd] )) && (( CURRENT == 2 )); then
28                 _systemd_analyze_$cmd
29             else
30                 _message "no more options"
31             fi
32         else
33             _message "unknown systemd-analyze command: $words[1]"
34         fi
35     fi
36 }
37
38 _arguments \
39     {-h,--help}'[Show help text.]' \
40     '--user[Shows performance data of user sessions instead of the system manager.]' \
41     '--order[When generating graph for dot, show only order]' \
42     '--require[When generating graph for dot, show only requirement]' \
43     '*::systemd-analyze commands:_systemd_analyze_command'