]> git.ipfire.org Git - thirdparty/systemd.git/blob - shell-completion/zsh/_systemd-analyze
Merge pull request #13365 from keszybz/fix-commits-from-pr-13246
[thirdparty/systemd.git] / shell-completion / zsh / _systemd-analyze
1 #compdef systemd-analyze -*- shell-script -*-
2 # SPDX-License-Identifier: LGPL-2.1+
3
4 (( $+functions[_systemd-analyze_log-level] )) ||
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 }
10
11 (( $+functions[_systemd-analyze_log-target] )) ||
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 }
17
18 (( $+functions[_systemd-analyze_verify] )) ||
19 _systemd-analyze_verify() {
20 _sd_unit_files
21 }
22
23 (( $+functions[_systemd-analyze_service-watchdogs] )) ||
24 _systemd-analyze_service-watchdogs() {
25 local -a _states
26 _states=(on off)
27 _describe -t state 'state' _states || compadd "$@"
28 }
29
30 (( $+functions[_systemd-analyze_commands] )) ||
31 _systemd-analyze_commands(){
32 local -a _systemd_analyze_cmds
33 # Descriptions taken from systemd-analyze --help.
34 _systemd_analyze_cmds=(
35 'time:Print time spent in the kernel before reaching userspace'
36 'blame:Print list of running units ordered by time to init'
37 'critical-chain:Print a tree of the time critical chain of units'
38 'plot:Output SVG graphic showing service initialization'
39 'dot:Dump dependency graph (in dot(1) format)'
40 'dump:Dump server status'
41 'unit-paths:List unit load paths'
42 'log-level:Get/set systemd log threshold'
43 'log-target:Get/set systemd log target'
44 'service-watchdogs:Get/set service watchdog status'
45 'syscall-filter:List syscalls in seccomp filter'
46 'verify:Check unit files for correctness'
47 'calendar:Validate repetitive calendar time events'
48 )
49
50 if (( CURRENT == 1 )); then
51 _describe "options" _systemd_analyze_cmds
52 else
53 local curcontext="$curcontext"
54 cmd="${${_systemd_analyze_cmds[(r)$words[1]:*]%%:*}}"
55 if (( $#cmd )); then
56 if (( $+functions[_systemd-analyze_$cmd] )) && (( CURRENT == 2 )); then
57 _systemd-analyze_$cmd
58 else
59 _message "no more options"
60 fi
61 else
62 _message "unknown systemd-analyze command: $words[1]"
63 fi
64 fi
65 }
66
67 _arguments \
68 {-h,--help}'[Show help text]' \
69 '--version[Show package version]' \
70 '--system[Operate on system systemd instance]' \
71 '--user[Operate on user systemd instance]' \
72 '--global[Show global user instance config]' \
73 '--no-pager[Do not pipe output into a pager]' \
74 '--man=[Do (not) check for existence of man pages]:boolean:(1 0)' \
75 '--order[When generating graph for dot, show only order]' \
76 '--require[When generating graph for dot, show only requirement]' \
77 '--fuzz=[When printing the tree of the critical chain, print also services, which finished TIMESPAN earlier, than the latest in the branch]:TIMESPAN' \
78 '--from-pattern=[When generating a dependency graph, filter only origins]:GLOB' \
79 '--to-pattern=[When generating a dependency graph, filter only destinations]:GLOB' \
80 {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \
81 {-M+,--machine=}'[Operate on local container]:machine:_sd_machines' \
82 '*::systemd-analyze commands:_systemd-analyze_commands'