]> git.ipfire.org Git - thirdparty/systemd.git/blob - shell-completion/zsh/_systemd-analyze
improve zsh completion (#32098)
[thirdparty/systemd.git] / shell-completion / zsh / _systemd-analyze
1 #compdef systemd-analyze
2 # SPDX-License-Identifier: LGPL-2.1-or-later
3
4 (( $+functions[_systemd-analyze_verify] )) ||
5 _systemd-analyze_verify() {
6 _sd_unit_files
7 }
8
9 (( $+functions[_systemd-analyze_cat-config] )) ||
10 _systemd-analyze_cat-config() {
11 _files -W '(/run/systemd/ /etc/systemd/ /usr/lib/systemd/)' -P 'systemd/'
12 }
13
14 (( $+functions[_systemd-analyze_critical-chain] )) ||
15 _systemd-analyze_critical-chain() {
16 local -a _units
17 systemctl list-units --no-legend --no-pager --plain --all |
18 while read -r a b c; do
19 _units+=($a)
20 done
21 compadd -a _units
22 }
23
24 (( $+functions[_systemd-analyze_security] )) ||
25 _systemd-analyze_security() {
26 _sd_unit_files
27 }
28
29 (( $+functions[_systemd-analyze_syscall-filter] )) ||
30 _systemd-analyze_syscall-filter() {
31 local -a _groups
32 _groups=( $(systemd-analyze --quiet --no-pager syscall-filter | grep '^@') )
33 _describe -t groups 'syscall groups' _groups || compadd "$@"
34 }
35
36 (( $+functions[_systemd-analyze_filesystems] )) ||
37 _systemd-analyze_filesystems() {
38 local -a _groups
39 _groups=( $(systemd-analyze --quiet --no-pager filesystems | grep '^@') )
40 _describe -t groups 'file system groups' _groups || compadd "$@"
41 }
42
43 (( $+functions[_systemd-analyze_plot] )) ||
44 _systemd-analyze_plot() {
45 local -a _options
46 _options=( '--json=off' '--json=pretty' '--json=short' '--table' '--no-legend' )
47 _describe 'plot options' _options
48 }
49
50 (( $+functions[_systemd-analyze_commands] )) ||
51 _systemd-analyze_commands(){
52 local -a _systemd_analyze_cmds
53 # Descriptions taken from systemd-analyze --help.
54 _systemd_analyze_cmds=(
55 'time:Print time spent in the kernel before reaching userspace'
56 'blame:Print list of running units ordered by time to init'
57 'critical-chain:Print a tree of the time critical chain of units'
58 'plot:Output SVG graphic showing service initialization, or raw time data in
59 JSON or table format'
60 'dot:Dump dependency graph (in dot(1) format)'
61 'dump:Dump server status'
62 'cat-config:Cat systemd config files'
63 'unit-files:List files and symlinks for units'
64 'unit-paths:List unit load paths'
65 'exit-status:List known exit statuses'
66 'capability:List capability definitions'
67 'syscall-filter:List syscalls in seccomp filters'
68 'filesystems:List known filesystems'
69 'condition:Evaluate Condition*= and Assert*= assignments'
70 'verify:Check unit files for correctness'
71 'calendar:Validate repetitive calendar time events'
72 'timestamp:Parse a systemd syntax timestamp'
73 'timespan:Parse a systemd syntax timespan'
74 'security:Analyze security settings of a service'
75 'inspect-elf:Parse and print ELF package metadata'
76 # log-level, log-target, service-watchdogs have been deprecated
77 )
78
79 if (( CURRENT == 1 )); then
80 _describe "options" _systemd_analyze_cmds
81 else
82 local curcontext="$curcontext"
83 cmd="${${_systemd_analyze_cmds[(r)$words[1]:*]%%:*}}"
84 if (( $#cmd )); then
85 if (( $+functions[_systemd-analyze_$cmd] )) && (( CURRENT == 2 )); then
86 _systemd-analyze_$cmd
87 else
88 _message "no more options"
89 fi
90 else
91 _message "unknown systemd-analyze command: $words[1]"
92 fi
93 fi
94 }
95
96 _arguments \
97 '(- *)'{-h,--help}'[Show help text]' \
98 '(- *)--version[Show package version]' \
99 '--system[Operate on system systemd instance]' \
100 '--user[Operate on user systemd instance]' \
101 '--global[Show global user instance config]' \
102 '--root=[Add support for root argument]:PATH' \
103 '--image=[Add support for discrete images]:PATH' \
104 '--recursive-errors=[When verifying a unit, control dependency verification]:MODE' \
105 '--offline=[Perform a security review of the specified unit files]:BOOL:(yes no)' \
106 '--threshold=[Set a value to compare the overall security exposure level with]: NUMBER' \
107 '--security-policy=[Use customized requirements to compare unit files against]: PATH' \
108 "--json=[Generate a JSON output of the security analysis table or plot's raw time data]:MODE:(pretty short off)" \
109 "--table=[Generate a table of plot's raw time data]" \
110 '--profile=[Include the specified profile in the security review of units]: PATH' \
111 '--no-pager[Do not pipe output into a pager]' \
112 "--no-legend[Do not show the headers and footers for plot's raw time data formats]" \
113 '--man=[Do (not) check for existence of man pages]:BOOL:(yes no)' \
114 '--generators=[Do (not) run unit generators]:BOOL:(yes no)' \
115 '--order[When generating graph for dot, show only order]' \
116 '--require[When generating graph for dot, show only requirement]' \
117 '--fuzz=[When printing the tree of the critical chain, print also services, which finished TIMESPAN earlier, than the latest in the branch]:TIMESPAN' \
118 '--from-pattern=[When generating a dependency graph, filter only origins]:GLOB' \
119 '--to-pattern=[When generating a dependency graph, filter only destinations]:GLOB' \
120 '(-H --host)'{-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \
121 '(-M --machine)'{-M+,--machine=}'[Operate on local container]:machine:_sd_machines' \
122 '--quiet[Do not show hints]' \
123 '*::systemd-analyze commands:_systemd-analyze_commands'