7abfbe7903d8e792850ec39286a3d86e616a6477William Giokas#compdef systemd-analyze
fe05567c31cb88593a09ce5d8961d8b20627feb1Zbigniew Jędrzejewski-Szmek_systemd_analyze_set-log-level() {
fe05567c31cb88593a09ce5d8961d8b20627feb1Zbigniew Jędrzejewski-Szmek local -a _levels
fe05567c31cb88593a09ce5d8961d8b20627feb1Zbigniew Jędrzejewski-Szmek _levels=(debug info notice warning err crit alert emerg)
fe05567c31cb88593a09ce5d8961d8b20627feb1Zbigniew Jędrzejewski-Szmek _describe -t level 'logging level' _levels || compadd "$@"
2c12a402cb1e8277c271ced8dc9c06d20b8f6017Zbigniew Jędrzejewski-Szmek_systemd_analyze_verify() {
7abfbe7903d8e792850ec39286a3d86e616a6477William Giokas_systemd_analyze_command(){
7abfbe7903d8e792850ec39286a3d86e616a6477William Giokas local -a _systemd_analyze_cmds
7abfbe7903d8e792850ec39286a3d86e616a6477William Giokas # Descriptions taken from systemd-analyze --help.
7abfbe7903d8e792850ec39286a3d86e616a6477William Giokas _systemd_analyze_cmds=(
7abfbe7903d8e792850ec39286a3d86e616a6477William Giokas 'time:Print time spent in the kernel before reaching userspace'
7abfbe7903d8e792850ec39286a3d86e616a6477William Giokas 'blame:Print list of running units ordered by time to init'
7abfbe7903d8e792850ec39286a3d86e616a6477William Giokas 'critical-chain:Print a tree of the time critical chain of units'
7abfbe7903d8e792850ec39286a3d86e616a6477William Giokas 'plot:Output SVG graphic showing service initialization'
7abfbe7903d8e792850ec39286a3d86e616a6477William Giokas 'dot:Dump dependency graph (in dot(1) format)'
299c397c127cda34facbe7d089f944a708ec95e9Zbigniew Jędrzejewski-Szmek 'dump:Dump server status'
fe05567c31cb88593a09ce5d8961d8b20627feb1Zbigniew Jędrzejewski-Szmek 'set-log-level:Set systemd log threshold'
2c12a402cb1e8277c271ced8dc9c06d20b8f6017Zbigniew Jędrzejewski-Szmek 'verify:Check unit files for correctness'
7abfbe7903d8e792850ec39286a3d86e616a6477William Giokas if (( CURRENT == 1 )); then
7abfbe7903d8e792850ec39286a3d86e616a6477William Giokas _describe "options" _systemd_analyze_cmds
fe05567c31cb88593a09ce5d8961d8b20627feb1Zbigniew Jędrzejewski-Szmek local curcontext="$curcontext"
fe05567c31cb88593a09ce5d8961d8b20627feb1Zbigniew Jędrzejewski-Szmek cmd="${${_systemd_analyze_cmds[(r)$words[1]:*]%%:*}}"
fe05567c31cb88593a09ce5d8961d8b20627feb1Zbigniew Jędrzejewski-Szmek if (( $#cmd )); then
fe05567c31cb88593a09ce5d8961d8b20627feb1Zbigniew Jędrzejewski-Szmek if (( $+functions[_systemd_analyze_$cmd] )) && (( CURRENT == 2 )); then
fe05567c31cb88593a09ce5d8961d8b20627feb1Zbigniew Jędrzejewski-Szmek _systemd_analyze_$cmd
fe05567c31cb88593a09ce5d8961d8b20627feb1Zbigniew Jędrzejewski-Szmek _message "no more options"
fe05567c31cb88593a09ce5d8961d8b20627feb1Zbigniew Jędrzejewski-Szmek _message "unknown systemd-analyze command: $words[1]"
26bd71f06c842585b184c3c2f29376564102232dRonny Chevalier {-h,--help}'[Show help text]' \
26bd71f06c842585b184c3c2f29376564102232dRonny Chevalier '--version[Show package version]' \
26bd71f06c842585b184c3c2f29376564102232dRonny Chevalier '--system[Operate on system systemd instance]' \
26bd71f06c842585b184c3c2f29376564102232dRonny Chevalier '--user[Operate on user systemd instance]' \
26bd71f06c842585b184c3c2f29376564102232dRonny Chevalier '--no-pager[Do not pipe output into a pager]' \
cc98b3025eeb89addb76a27390cb2baca4eab8b9Torstein Husebø '--man=[Do (not) check for existence of man pages]:boolean:(1 0)' \
7abfbe7903d8e792850ec39286a3d86e616a6477William Giokas '--order[When generating graph for dot, show only order]' \
7abfbe7903d8e792850ec39286a3d86e616a6477William Giokas '--require[When generating graph for dot, show only requirement]' \
26bd71f06c842585b184c3c2f29376564102232dRonny Chevalier '--fuzz=[When printing the tree of the critical chain, print also services, which finished TIMESPAN earlier, than the latest in the branch]:TIMESPAN' \
26bd71f06c842585b184c3c2f29376564102232dRonny Chevalier '--from-pattern=[When generating a dependency graph, filter only origins]:GLOB' \
26bd71f06c842585b184c3c2f29376564102232dRonny Chevalier '--to-pattern=[When generating a dependency graph, filter only destinations]:GLOB' \
2c12a402cb1e8277c271ced8dc9c06d20b8f6017Zbigniew Jędrzejewski-Szmek {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \
b93f15cd056ca71b7e0aa0560992da345e87f974Lukas Rusak {-M+,--machine=}'[Operate on local container]:machine:_sd_machines' \
7abfbe7903d8e792850ec39286a3d86e616a6477William Giokas '*::systemd-analyze commands:_systemd_analyze_command'