chiark / gitweb /
69087250409c9eb41b2ee67d1a823c3dcc93d5a1
[elogind.git] / shell-completion / zsh / _systemd
1 #compdef systemd-analyze systemd-cat systemd-ask-password systemd-cgls systemd-cgtop systemd-delta systemd-detect-virt systemd-machine-id-setup systemd-notify systemd-tmpfiles systemd-tty-ask-password-agent machinectl
2
3 _ctls()
4 {
5     local curcontext="$curcontext" state lstate line
6     case "$service" in
7         systemd-analyze)
8             _arguments \
9                 {-h,--help}'[Show help text.]' \
10                 '--user[Shows performance data of user sessions instead of the system manager.]' \
11                 '--order[When generating graph for dot, show only order]' \
12                 '--require[When generating graph for dot, show only requirement]' \
13                 '*::systemd-analyze commands:_systemd_analyze_command'
14         ;;
15         systemd-ask-password)
16             _arguments \
17                 {-h,--help}'[Show this help]' \
18                 '--icon=[Icon name]' \
19                 '--timeout=[Timeout in sec]' \
20                 '--no-tty[Ask question via agent even on TTY]' \
21                 '--accept-cached[Accept cached passwords]' \
22                 '--multiple[List multiple passwords if available]'
23         ;;
24         systemd-cat)
25             _arguments \
26                 {-h,--help}'[Show this help]' \
27                 '--version[Show package version.]' \
28                 {-t,--identifier=}'[Set syslog identifier.]' \
29                 {-p,--priority=}'[Set priority value.]:value:({0..7})' \
30                 '--level-prefix=[Control whether level prefix shall be parsed.]:boolean:(1 0)' \
31                 ':Message'
32         ;;
33         systemd-cgls)
34             _arguments \
35                 {-h,--help}'[Show this help]' \
36                 '--version[Show package version]' \
37                 '--no-pager[Do not pipe output into a pager]' \
38                 {-a,--all}'[Show all groups, including empty]' \
39                 '-k[Include kernel threads in output]' \
40                 ':cgroups:(cpuset cpu cpuacct memory devices freezer net_cls blkio)'
41         ;;
42         systemd-cgtop)
43             _arguments \
44                 {-h,--help}'[Show this help]' \
45                 '--version[Print version and exit]' \
46                 '(-c -m -i -t)-p[Order by path]' \
47                 '(-c -p -m -i)-t[Order by number of tasks]' \
48                 '(-m -p -i -t)-c[Order by CPU load]' \
49                 '(-c -p -i -t)-m[Order by memory load]' \
50                 '(-c -m -p -t)-i[Order by IO load]' \
51                 {-d,--delay=}'[Specify delay]' \
52                 {-n,--iterations=}'[Run for N iterations before exiting]' \
53                 {-b,--batch}'[Run in batch mode, accepting no input]' \
54                 '--depth=[Maximum traversal depth]'
55         ;;
56         systemd-delta)
57             _arguments \
58                 {-h,--help}'[Show this help]' \
59                 '--version[Show package version]' \
60                 '--no-pager[Do not pipe output into a pager]' \
61                 '--diff=[Show a diff when overridden files differ]:boolean:(1 0)' \
62                 {-t,--type=}'[Only display a selected set of override types]:types:(masked equivalent redirected overridden unchanged)' \
63                 ':SUFFIX:(tmpfiles.d sysctl.d systemd/system)'
64         ;;
65         systemd-detect-virt)
66             _arguments \
67                 {-h,--help}'[Show this help]' \
68                 '--version[Show package version]' \
69                 {-c,--container}'[Only detect whether we are run in a container]' \
70                 {-v,--vm}'[Only detect whether we are run in a VM]' \
71                 {-q,--quiet}"[Don't output anything, just set return value]"
72         ;;
73         systemd-machine-id-setup)
74             _arguments \
75                 {-h,--help}'[Show this help]' \
76                 '--version[Show package version]'
77         ;;
78         systemd-notify)
79             _arguments \
80                 {-h,--help}'[Show this help]' \
81                 '--version[Show package version]' \
82                 '--ready[Inform the init system about service start-up completion.]' \
83                 '--pid=[Inform the init system about the main PID of the daemon]' \
84                 '--status=[Send a free-form status string for the daemon to the init systemd]' \
85                 '--booted[Returns 0 if the system was booted up with systemd]' \
86                 '--readahead=[Controls disk read-ahead operations]:arguments:(cancel done noreply)'
87         ;;
88         systemd-tmpfiles)
89             _arguments \
90                 '--create[Create, set ownership/permissions based on the config files.]' \
91                 '--clean[Clean up all files and directories with an age parameter configured.]' \
92                 '--remove[All files and directories marked with r, R in the configuration files are removed.]' \
93                 '--prefix=[Only apply rules that apply to paths with the specified prefix.]' \
94                 '--exclude-prefix=[Ignore rules that apply to paths with the specified prefix.]' \
95                 '--help[Prints a short help text and exits.]' \
96                 '*::files:_files'
97         ;;
98         systemd-tty-ask-password-agent)
99             _arguments \
100                 {-h,--help}'[Prints a short help text and exits.]' \
101                 '--version[Prints a short version string and exits.]' \
102                 '--list[Lists all currently pending system password requests.]' \
103                 '--query[Process all currently pending system password requests by querying the user on the calling TTY.]' \
104                 '--watch[Continuously process password requests.]' \
105                 '--wall[Forward password requests to wall(1).]' \
106                 '--plymouth[Ask question with plymouth(8).]' \
107                 '--console[Ask question on /dev/console.]'
108         ;;
109         machinectl)
110             _arguments \
111                 {-h,--help}'[Prints a short help text and exits.]' \
112                 '--version[Prints a short version string and exits.]' \
113                 {-p,--property=}'[Limit output to specified property.]:property:(Name Id Timestamp TimestampMonotonic Service Scope Leader Class State RootDirectory)' \
114                 {-a,--all}'[Show all proerties]' \
115                 (-l,--full)'[Do not ellipsize cgroup members]' \
116                 '--no-pager[Do not pipe output into a pager]' \
117                 '--no-ask-password[Do not ask for system passwords]' \
118                 '--kill-who=[Who to send signal to]:killwho:(leader all)' \
119                 {-s,--signal=}'[Which signal to send]:signal:_signals' \
120                 {-H,--host=}'[Show information for remote host]:userathost:_hosts_or_user_at_host' \
121                 {-P,--privileged}'[Acquire privileges before execution]' \
122                 '*::machinectl command:_machinectl_command'
123         ;;
124         *) _message 'eh?' ;;
125     esac
126 }
127
128 _systemd_analyze_command(){
129     local -a _systemd_analyze_cmds
130     # Descriptions taken from systemd-analyze --help.
131     _systemd_analyze_cmds=(
132         'time:Print time spent in the kernel before reaching userspace'
133         'blame:Print list of running units ordered by time to init'
134         'critical-chain:Print a tree of the time critical chain of units'
135         'plot:Output SVG graphic showing service initialization'
136         'dot:Dump dependency graph (in dot(1) format)'
137     )
138
139     if (( CURRENT == 1 )); then
140         _describe "options" _systemd_analyze_cmds
141     else
142         _message "no more options"
143     fi
144 }
145
146 _hosts_or_user_at_host()
147 {
148   _alternative \
149     'users-hosts:: _user_at_host' \
150     'hosts:: _hosts'
151 }
152
153 _outputmodes() {
154     local -a _output_opts
155     _output_opts=(short short-monotonic verbose export json json-pretty json-see cat)
156     _describe -t output 'output mode' _output_opts || compadd "$@"
157 }
158
159 (( $+functions[_machinectl_command] )) || _machinectl_command()
160 {
161   local -a _machinectl_cmds
162   _machinectl_cmds=(
163     "list:List currently running VMs/containers"
164     "status:Show VM/container status"
165     "show:Show properties of one or more VMs/containers"
166     "terminate:Terminate one or more VMs/containers"
167     "kill:Send signal to process or a VM/container"
168   )
169   if (( CURRENT == 1 )); then
170     _describe -t commands 'machinectl command' _machinectl_cmds || compadd "$@"
171   else
172     local curcontext="$curcontext"
173     cmd="${${_machinectl_cmds[(r)$words[1]:*]%%:*}}"
174     if (( $#cmd )); then
175       case $cmd in
176         list) msg="no options" ;;
177         *)
178           _machines=( "${(foa)$(machinectl list | awk '{print $1}')}" )
179           if [[ -n "$_machines" ]]; then
180             _describe 'machines' _machines
181           else
182             _message 'no machines'
183           fi
184       esac
185     else
186       _message "no more options"
187     fi
188   fi
189 }
190
191 _ctls "$@"
192
193 #vim: set ft=zsh sw=4 ts=4 et