chiark / gitweb /
ce7ea1ad4d47d8921bc21d12579ba60b6da93c06
[elogind.git] / shell-completion / zsh / _systemd
1 #compdef journalctl localectl timedatectl systemd-coredumpctl udevadm systemd-analyze systemd-cat systemd-ask-password systemd-cgls systemd-cgtop systemd-delta systemd-detect-virt systemd-inhibit systemd-machine-id-setup systemd-notify systemd-nspawn systemd-tmpfiles systemd-tty-ask-password-agent machinectl
2
3 _ctls()
4 {
5     local curcontext="$curcontext" state lstate line
6     case "$service" in
7         journalctl)
8             _arguments -s \
9                 '--since=[Start showing entries newer or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
10                 '--until=[Stop showing entries older or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
11                 {-c,--cursor=}'[Start showing entries from specified cursor]:cursors:_journal_fields __CURSORS' \
12                 '--system[Show system and kernel messages]' \
13                 '--user[Show messages from user services]' \
14                 {-b,--this-boot}'[Show data only from current boot]' \
15                 {-u,--unit=}'[Show data only from the specified unit]:units:_journal_fields _SYSTEMD_UNIT' \
16                 '--user-unit[Show data only from the specified user session unit]:units:_journal_fields _SYSTEMD_USER_UNIT' \
17                 {-p,--priority=}'[Show only messages within the specified priority range]:priority:_journal_fields PRIORITY' \
18                 {-f,--follow}'[Follow journal]' \
19                 {-n,--lines=}'[Number of journal entries to show]:integer' \
20                 '--no-tail[Show all lines, even in follow mode]' \
21                 {-o,--output=}'[Change journal output mode]:output modes:_outputmodes' \
22                 {-l,--full}'[Show long fields in full]' \
23                 {-a,--all}'[Show all fields, including long and unprintable]' \
24                 {-q,--quiet}"[Don't show privilege warning]" \
25                 '--no-pager[Do not pipe output into a pager]' \
26                 {-m,--merge}'[Show entries from all available journals]' \
27                 {-D,--directory=}'[Show journal files from directory]:directories:_directories' \
28                 '--interval=[Time interval for changing the FSS sealing key]:time interval' \
29                 '--verify-key=[Specify FSS verification key]:FSS key' \
30                 {-h,--help}'[Show this help]' \
31                 '--version[Show package version]' \
32                 '--new-id128[Generate a new 128 Bit ID]' \
33                 '--header[Show journal header information]' \
34                 '--disk-usage[Show total disk usage]' \
35                 {-F,--field=}'[List all values a certain field takes]:Fields:_list_fields' \
36                 '--setup-keys[Generate new FSS key pair]' \
37                 '--verify[Verify journal file consistency]' \
38                 '--list-catalog[List messages in catalog]' \
39                 '--update-catalog[Update binary catalog database]' \
40                 '*::default: _journal_none'
41         ;;
42         localectl)
43             _arguments \
44                 {-h,--help}'[Show this help]' \
45                 '--version[Show package version]' \
46                 "--no-convert[Don't convert keyboard mappings]" \
47                 '--no-pager[Do not pipe output into a pager]' \
48                 '--no-ask-password[Do not prompt for password]' \
49                 {-H,--host=}'[Operate on remote host]:userathost:_hosts_or_user_at_host' \
50                 '*::localectl commands:_localectl_command'
51         ;;
52         systemd-coredumpctl)
53             _arguments \
54                 {-o,--output=}'[Write output to FILE]:output file:_files' \
55                 '--no-pager[Do not pipe output into a pager]' \
56                 {-h,--help}'[Show this help]' \
57                 '--version[Show package version]' \
58                 '*::systemd-coredumpctl commands:_systemd-coredumpctl_command'
59
60         ;;
61         timedatectl)
62             _arguments -s \
63                 {-h,--help}'[Show this help]' \
64                 '--version[Show package version]' \
65                 '--adjust-system-clock[Adjust system clock when changing local RTC mode]' \
66                 '--no-pager[Do not pipe output into a pager]' \
67                 '--no-ask-password[Do not prompt for password]' \
68                 {-H,--host=}'[Operate on remote host]:userathost:_hosts_or_user_at_host' \
69                 '*::timedatectl commands:_timedatectl_command'
70         ;;
71         udevadm)
72             _arguments \
73                 '--debug[Print debug messages to stderr]' \
74                 '--version[Print version number]' \
75                 '--help[Print help text]' \
76                 '*::udevadm commands:_udevadm_command'
77         ;;
78         systemd-analyze)
79             _arguments \
80                 {-h,--help}'[Show help text.]' \
81                 '--user[Shows performance data of user sessions instead of the system manager.]' \
82                 '--order[When generating graph for dot, show only order]' \
83                 '--require[When generating graph for dot, show only requirement]' \
84                 '*::systemd-analyze commands:_systemd_analyze_command'
85         ;;
86         systemd-ask-password)
87             _arguments \
88                 {-h,--help}'[Show this help]' \
89                 '--icon=[Icon name]' \
90                 '--timeout=[Timeout in sec]' \
91                 '--no-tty[Ask question via agent even on TTY]' \
92                 '--accept-cached[Accept cached passwords]' \
93                 '--multiple[List multiple passwords if available]'
94         ;;
95         systemd-cat)
96             _arguments \
97                 {-h,--help}'[Show this help]' \
98                 '--version[Show package version.]' \
99                 {-t,--identifier=}'[Set syslog identifier.]' \
100                 {-p,--priority=}'[Set priority value.]:value:({0..7})' \
101                 '--level-prefix=[Control whether level prefix shall be parsed.]:boolean:(1 0)' \
102                 ':Message'
103         ;;
104         systemd-cgls)
105             _arguments \
106                 {-h,--help}'[Show this help]' \
107                 '--version[Show package version]' \
108                 '--no-pager[Do not pipe output into a pager]' \
109                 {-a,--all}'[Show all groups, including empty]' \
110                 '-k[Include kernel threads in output]' \
111                 ':cgroups:(cpuset cpu cpuacct memory devices freezer net_cls blkio)'
112         ;;
113         systemd-cgtop)
114             _arguments \
115                 {-h,--help}'[Show this help]' \
116                 '--version[Print version and exit]' \
117                 '(-c -m -i -t)-p[Order by path]' \
118                 '(-c -p -m -i)-t[Order by number of tasks]' \
119                 '(-m -p -i -t)-c[Order by CPU load]' \
120                 '(-c -p -i -t)-m[Order by memory load]' \
121                 '(-c -m -p -t)-i[Order by IO load]' \
122                 {-d,--delay=}'[Specify delay]' \
123                 {-n,--iterations=}'[Run for N iterations before exiting]' \
124                 {-b,--batch}'[Run in batch mode, accepting no input]' \
125                 '--depth=[Maximum traversal depth]'
126         ;;
127         systemd-delta)
128             _arguments \
129                 {-h,--help}'[Show this help]' \
130                 '--version[Show package version]' \
131                 '--no-pager[Do not pipe output into a pager]' \
132                 '--diff=[Show a diff when overridden files differ]:boolean:(1 0)' \
133                 {-t,--type=}'[Only display a selected set of override types]:types:(masked equivalent redirected overridden unchanged)' \
134                 ':SUFFIX:(tmpfiles.d sysctl.d systemd/system)'
135         ;;
136         systemd-detect-virt)
137             _arguments \
138                 {-h,--help}'[Show this help]' \
139                 '--version[Show package version]' \
140                 {-c,--container}'[Only detect whether we are run in a container]' \
141                 {-v,--vm}'[Only detect whether we are run in a VM]' \
142                 {-q,--quiet}"[Don't output anything, just set return value]"
143         ;;
144         systemd-inhibit)
145             _arguments \
146                 {-h,--help}'[Show this help]' \
147                 '--version[Show package version]' \
148                 '--what=[Operations to inhibit]:options:(shutdown sleep idle handle-power-key handle-suspend-key handle-hibernate-key handle-lid-switch)' \
149                 '--who=[A descriptive string who is inhibiting]' \
150                 '--why=[A descriptive string why is being inhibited]' \
151                 '--mode=[One of block or delay]' \
152                 '--list[List active inhibitors]' \
153                 '*:commands:_systemd_inhibit_command'
154         ;;
155         systemd-machine-id-setup)
156             _arguments \
157                 {-h,--help}'[Show this help]' \
158                 '--version[Show package version]'
159         ;;
160         systemd-notify)
161             _arguments \
162                 {-h,--help}'[Show this help]' \
163                 '--version[Show package version]' \
164                 '--ready[Inform the init system about service start-up completion.]' \
165                 '--pid=[Inform the init system about the main PID of the daemon]' \
166                 '--status=[Send a free-form status string for the daemon to the init systemd]' \
167                 '--booted[Returns 0 if the system was booted up with systemd]' \
168                 '--readahead=[Controls disk read-ahead operations]:arguments:(cancel done noreply)'
169         ;;
170         systemd-nspawn)
171             _arguments \
172                 {-h,--help}'[Show this help]' \
173                 {--directory=,-D}'[Directory to use as file system root for the namespace container. If omitted the current directory will be used.]:directories:_directories' \
174                 {--boot,-b}'[Automatically search for an init binary and invoke it instead of a shell or a user supplied program.]' \
175                 {--user=,-u}'[Run the command under specified user, create home directory and cd into it.]' \
176                 '--uuid=[Set the specified uuid for the container.]' \
177                 {--controllers=,-C}'[Makes the container appear in other hierarchies than the name=systemd:/ one. Takes a comma-separated list of controllers.]' \
178                 '--private-network[Turn off networking in the container. This makes all network interfaces unavailable in the container, with the exception of the loopback device.]' \
179                 '--read-only[Mount the root file system read only for the container.]' \
180                 '--capability=[List one or more additional capabilities to grant the container.]:capabilities:_systemd-nspawn' \
181                 "--link-journal=[Control whether the container's journal shall be made visible to the host system.]:options:(no, host, guest, auto)" \
182                 '-j[Equivalent to --link-journal=guest.]'
183         ;;
184         systemd-tmpfiles)
185             _arguments \
186                 '--create[Create, set ownership/permissions based on the config files.]' \
187                 '--clean[Clean up all files and directories with an age parameter configured.]' \
188                 '--remove[All files and directories marked with r, R in the configuration files are removed.]' \
189                 '--prefix=[Only apply rules that apply to paths with the specified prefix.]' \
190                 '--exclude-prefix=[Ignore rules that apply to paths with the specified prefix.]' \
191                 '--help[Prints a short help text and exits.]' \
192                 '*::files:_files'
193         ;;
194         systemd-tty-ask-password-agent)
195             _arguments \
196                 {-h,--help}'[Prints a short help text and exits.]' \
197                 '--version[Prints a short version string and exits.]' \
198                 '--list[Lists all currently pending system password requests.]' \
199                 '--query[Process all currently pending system password requests by querying the user on the calling TTY.]' \
200                 '--watch[Continuously process password requests.]' \
201                 '--wall[Forward password requests to wall(1).]' \
202                 '--plymouth[Ask question with plymouth(8).]' \
203                 '--console[Ask question on /dev/console.]'
204         ;;
205         machinectl)
206             _arguments \
207                 {-h,--help}'[Prints a short help text and exits.]' \
208                 '--version[Prints a short version string and exits.]' \
209                 {-p,--property=}'[Limit output to specified property.]:property:(Name Id Timestamp TimestampMonotonic Service Scope Leader Class State RootDirectory)' \
210                 {-a,--all}'[Show all proerties]' \
211                 (-l,--full)'[Do not ellipsize cgroup members]' \
212                 '--no-pager[Do not pipe output into a pager]' \
213                 '--no-ask-password[Do not ask for system passwords]' \
214                 '--kill-who=[Who to send signal to]:killwho:(leader all)' \
215                 {-s,--signal=}'[Which signal to send]:signal:_signals' \
216                 {-H,--host=}'[Show information for remote host]:userathost:_hosts_or_user_at_host' \
217                 {-P,--privileged}'[Acquire privileges before execution]' \
218                 '*::machinectl command:_machinectl_command'
219         ;;
220         *) _message 'eh?' ;;
221     esac
222 }
223
224 _systemd-nspawn(){
225     local -a _caps
226     _caps=( CAP_CHOWN CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH
227             CAP_FOWNER CAP_FSETID CAP_IPC_OWNER CAP_KILL CAP_LEASE CAP_LINUX_IMMUTABLE
228             CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SETGID CAP_SETFCAP CAP_SETPCAP
229             CAP_SETUID CAP_SYS_ADMIN CAP_SYS_CHROOT CAP_SYS_NICE CAP_SYS_PTRACE CAP_SYS_TTY_CONFIG
230             CAP_SYS_RESOURCE CAP_SYS_BOOT )
231     _values -s , 'capabilities' "$_caps[@]"
232 }
233
234 _systemd_inhibit_command(){
235     if (( CURRENT == 1 )); then
236         compset -q
237         _normal
238     else
239         local n=${words[(b:2:i)[^-]*]}
240         if (( n <= CURRENT )); then
241             compset -n $n
242             _alternative \
243                 'files:file:_files' \
244                 'commands:command:_normal' && return 0
245         fi
246         _default
247     fi
248
249 }
250
251 _systemd_analyze_command(){
252     local -a _systemd_analyze_cmds
253     # Descriptions taken from systemd-analyze --help.
254     _systemd_analyze_cmds=(
255         'time:Print time spent in the kernel before reaching userspace'
256         'blame:Print list of running units ordered by time to init'
257         'critical-chain:Print a tree of the time critical chain of units'
258         'plot:Output SVG graphic showing service initialization'
259         'dot:Dump dependency graph (in dot(1) format)'
260     )
261
262     if (( CURRENT == 1 )); then
263         _describe "options" _systemd_analyze_cmds
264     else
265         _message "no more options"
266     fi
267 }
268
269 _hosts_or_user_at_host()
270 {
271   _alternative \
272     'users-hosts:: _user_at_host' \
273     'hosts:: _hosts'
274 }
275
276 _outputmodes() {
277     local -a _output_opts
278     _output_opts=(short short-monotonic verbose export json json-pretty json-see cat)
279     _describe -t output 'output mode' _output_opts || compadd "$@"
280 }
281
282 _list_fields() {
283     local -a journal_fields
284     journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
285                     ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID}
286                     _{P,U,G}ID _COMM _EXE _CMDLINE
287                     _AUDIT_{SESSION,LOGINUID}
288                     _SYSTEMD_{CGROUP,SESSION,UNIT,OWNER_UID}
289                     _SYSTEMD_USER_UNIT
290                     _SELINUX_CONTEXT _SOURCE_REALTIME_TIMESTAMP
291                     _{BOOT,MACHINE}_ID _HOSTNAME _TRANSPORT
292                     _KERNEL_{DEVICE,SUBSYSTEM}
293                     _UDEV_{SYSNAME,DEVNODE,DEVLINK}
294                     __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP)
295     _describe 'possible fields' journal_fields
296 }
297
298 _journal_none() {
299     local -a _commands _files
300     _commands=( ${(f)"$(_call_program commands "$service" -F _EXE 2>/dev/null)"} )
301     _alternative : \
302         'files:/dev files:_files -W /dev -P /dev/' \
303         "commands:commands:($_commands[@])" \
304         'fields:fields:_list_fields'
305 }
306
307 _journal_fields() {
308     local -a _fields cmd
309     cmd=("journalctl" "-F ${@[-1]}" "2>/dev/null" )
310     _fields=( ${(f)"$(_call_program fields $cmd[@])"} )
311     typeset -U _fields
312     _describe 'possible values' _fields
313 }
314
315 _localectl_set-locale() {
316     local -a _confs _locales
317     local expl suf
318     _locales=( ${(f)"$(_call_program locales "$service" list-locales)"} )
319     _confs=( ${${(f)"$(_call_program confs "locale 2>/dev/null")"}%\=*} )
320     if [[ -prefix 1 *\= ]]; then
321         local conf=${PREFIX%%\=*}
322         compset -P1 '*='
323         _wanted locales expl "locales configs" \
324             _combination localeconfs  confs=$conf locales "$@" -
325     else
326         compadd -S '='  $_confs
327     fi
328 }
329
330 _localectl_set-keymap() {
331     local -a _keymaps
332     _keymaps=( ${(f)"$(_call_program locales "$service" list-keymaps)"} )
333     if (( CURRENT <= 3 )); then
334         _describe keymaps _keymaps
335     else
336         _message "no more options"
337     fi
338 }
339
340 _localectl_set-x11-keymap() {
341     if (( $+commands[pkg-config] )); then
342         local -a _file _layout _model _variant _options
343         local _xorg_lst
344         _xorg_lst=${"$($commands[pkg-config] xkeyboard-config --variable=xkb_base)"}
345         _file=( ${(ps:\n\!:)"$(<$_xorg_lst/rules/xorg.lst)"} )
346         _layout=( ${${${(M)${(f)_file[1]}:#  *}#  }%% *} )
347         _model=( ${${${(M)${(f)_file[2]}:#  *}#  }%% *} )
348         _variant=( ${${${(M)${(f)_file[3]}:#  *}#  }%% *} )
349         _options=( ${${${(M)${(f)_file[4]}:#  *}#  }%% *} )
350         #_layout=( ${(f)"$( echo $_file[1] | awk '/^  / {print $1}' )"} )
351         #_model=( ${(f)"$(echo $_file[2] | awk '/^  / {print $1}')"} )
352         #_variant=( ${(f)"$(echo $_file[3] | awk '/^  / {print $1}')"} )
353         #_options=( ${(f)"$(echo ${_file[4]//:/\\:} | awk '/^  / {print $1}')"} )
354
355         case $CURRENT in
356             2) _describe layouts _layout ;;
357             3) _describe models _model;;
358             4) _describe variants _variant;;
359             5) _describe options _options;;
360             *) _message "no more options"
361         esac
362     fi
363 }
364
365
366 _localectl_command() {
367     local -a _localectl_cmds
368     _localectl_cmds=(
369         'status:Show current locale settings'
370         'set-locale:Set system locale'
371         'list-locales:Show known locales'
372         'set-keymap:Set virtual console keyboard mapping'
373         'list-keymaps:Show known virtual console keyboard mappings'
374         'set-x11-keymap:Set X11 keyboard mapping'
375     )
376     if (( CURRENT == 1 )); then
377         _describe -t commands 'localectl command' _localectl_cmds
378     else
379         local curcontext="$curcontext"
380         cmd="${${_localectl_cmds[(r)$words[1]:*]%%:*}}"
381         if (( $+functions[_localectl_$cmd] )); then
382             _localectl_$cmd
383         else
384             _message "no more options"
385         fi
386     fi
387 }
388
389 _timedatectl_set-timezone(){
390     local -a _timezones
391     _timezones=( ${(f)"$(_call_program timezones "${service}" list-timezones)"} )
392     compadd "$_timezones[@]"
393 }
394
395 _timedatectl_set-time(){
396     _message "YYYY-MM-DD HH:MM:SS"
397 }
398
399 _timedatectl_set-local-rtc(){
400     local -a _options
401     _options=(
402         '0:Maintain RTC in universal time'
403         '1:Maintain RTC in local time'
404     )
405     _describe options _options
406 }
407
408 _timedatectl_set-ntp(){
409     local -a _options
410     _options=(
411         '0:Disable NTP based network time configuration'
412         '1:Enable NTP based network time configuration'
413     )
414     _describe options _options
415 }
416
417 _timedatectl_command(){
418     local -a _timedatectl_cmds
419     _timedatectl_cmds=(
420         'status:Show current time settings'
421         'set-time:Set system time'
422         'set-timezone:Set system timezone'
423         'list-timezones:Show known timezones'
424         'set-local-rtc:Control whether RTC is in local time'
425         'set-ntp:Control whether NTP is enabled'
426     )
427     if (( CURRENT == 1 )); then
428         _describe -t commands 'timedatectl command' _timedatectl_cmds
429     else
430         local curcontext="$curcontext"
431         cmd="${${_timedatectl_cmds[(r)$words[1]:*]%%:*}}"
432         if (( $#cmd )); then
433             if (( $+functions[_timedatectl_$cmd] )); then
434                 _timedatectl_$cmd
435             else
436                 _message "no more options"
437             fi
438         else
439             _message "unknown timedatectl command: $words[1]"
440         fi
441     fi
442 }
443 _systemd-coredumpctl_command(){
444     local -a _systemd_coredumpctl_cmds
445     _systemd_coredumpctl_cmds=(
446             'list:List available coredumps'
447             'dump:Print coredump to std'
448     )
449     if (( CURRENT == 1 )); then
450         _describe -t commands 'systemd-coredumpctl command' _systemd_coredumpctl_cmds
451     else
452         local curcontext="$curcontext"
453         local -a _dumps
454         cmd="${${_systemd_coredumpctl_cmds[(r)$words[1]:*]%%:*}}"
455         if (( $#cmd  )); then
456                         # user can set zstyle ':completion:*:*:systemd-coredumpctl:*' sort no for coredumps to be ordered by date, otherwise they get ordered by pid
457                         _dumps=( "${(foa)$(systemd-coredumpctl list | awk 'BEGIN{OFS=":"} /^\s/ {sub(/[[ \t]+/, ""); print $5,$0}' 2>/dev/null)}" )
458             if [[ -n "$_dumps" ]]; then
459                 _describe -t pids 'coredumps' _dumps
460             else
461                 _message "no coredumps"
462             fi
463         else
464             _message "no more options"
465         fi
466
467     fi
468
469 }
470
471 (( $+functions[_machinectl_command] )) || _machinectl_command()
472 {
473   local -a _machinectl_cmds
474   _machinectl_cmds=(
475     "list:List currently running VMs/containers"
476     "status:Show VM/container status"
477     "show:Show properties of one or more VMs/containers"
478     "terminate:Terminate one or more VMs/containers"
479     "kill:Send signal to process or a VM/container"
480   )
481   if (( CURRENT == 1 )); then
482     _describe -t commands 'machinectl command' _machinectl_cmds || compadd "$@"
483   else
484     local curcontext="$curcontext"
485     cmd="${${_machinectl_cmds[(r)$words[1]:*]%%:*}}"
486     if (( $#cmd )); then
487       case $cmd in
488         list) msg="no options" ;;
489         *)
490           _machines=( "${(foa)$(machinectl list | awk '{print $1}')}" )
491           if [[ -n "$_machines" ]]; then
492             _describe 'machines' _machines
493           else
494             _message 'no machines'
495           fi
496       esac
497     else
498       _message "no more options"
499     fi
500   fi
501 }
502
503 _udevadm_info(){
504     _arguments \
505         '--query=[Query the database for specified type of device data. It needs the --path or --name to identify the specified device.]:type:(name symlink path property all)' \
506         '--path=[The devpath of the device to query.]:sys files:_files -P /sys/ -W /sys' \
507         '--name=[The name of the device node or a symlink to query]:device files:_files -P /dev/ -W /dev' \
508         '--root[Print absolute paths in name or symlink query.]' \
509         '--attribute-walk[Print all sysfs properties of the specified device that can be used in udev rules to match the specified device]' \
510         '--export[Print output as key/value pairs.]' \
511         '--export-prefix=[Add a prefix to the key name of exported values.]:prefix' \
512         '--device-id-of-file=[Print major/minor numbers of the underlying device, where the file lives on.]:files:_udevadm_mounts' \
513         '--export-db[Export the content of the udev database.]' \
514         '--cleanup-db[Cleanup the udev database.]'
515 }
516
517 _udevadm_trigger(){
518     _arguments \
519         '--verbose[Print the list of devices which will be triggered.]' \
520         '--dry-run[Do not actually trigger the event.]' \
521         '--type=[Trigger a specific type of devices.]:types:(devices subsystems failed)' \
522         '--action=[Type of event to be triggered.]:actions:(add change remove)' \
523         '--subsystem-match=[Trigger events for devices which belong to a matching subsystem.]' \
524         '--subsystem-nomatch=[Do not trigger events for devices which belong to a matching subsystem.]' \
525         '--attr-match=attribute=[Trigger events for devices with a matching sysfs attribute.]' \
526         '--attr-nomatch=attribute=[Do not trigger events for devices with a matching sysfs attribute.]' \
527         '--property-match=[Trigger events for devices with a matching property value.]' \
528         '--tag-match=property[Trigger events for devices with a matching tag.]' \
529         '--sysname-match=[Trigger events for devices with a matching sys device name.]' \
530         '--parent-match=[Trigger events for all children of a given device.]'
531 }
532
533 _udevadm_settle(){
534     _arguments \
535        '--timeout=[Maximum number of seconds to wait for the event queue to become empty.]' \
536        '--seq-start=[Wait only for events after the given sequence number.]' \
537        '--seq-end=[Wait only for events before the given sequence number.]' \
538        '--exit-if-exists=[Stop waiting if file exists.]:files:_files' \
539        '--quiet[Do not print any output, like the remaining queue entries when reaching the timeout.]' \
540        '--help[Print help text.]'
541 }
542
543 _udevadm_control(){
544     _arguments \
545         '--exit[Signal and wait for systemd-udevd to exit.]' \
546         '--log-priority=[Set the internal log level of systemd-udevd.]:priorities:(err info debug)' \
547         '--stop-exec-queue[Signal systemd-udevd to stop executing new events. Incoming events will be queued.]' \
548         '--start-exec-queue[Signal systemd-udevd to enable the execution of events.]' \
549         '--reload[Signal systemd-udevd to reload the rules files and other databases like the kernel module index.]' \
550         '--property=[Set a global property for all events.]' \
551         '--children-max=[Set the maximum number of events.]' \
552         '--timeout=[The maximum number of seconds to wait for a reply from systemd-udevd.]' \
553         '--help[Print help text.]'
554 }
555
556 _udevadm_monitor(){
557     _arguments \
558         '--kernel[Print the kernel uevents.]' \
559         '--udev[Print the udev event after the rule processing.]' \
560         '--property[Also print the properties of the event.]' \
561         '--subsystem-match=[Filter events by subsystem/\[devtype\].]' \
562         '--tag-match=[Filter events by property.]' \
563         '--help[Print help text.]'
564 }
565
566 _udevadm_test(){
567     _arguments \
568         '--action=[The action string.]:actions:(add change remove)' \
569         '--subsystem=[The subsystem string.]' \
570         '--help[Print help text.]' \
571         '*::devpath:_files -P /sys/ -W /sys'
572 }
573
574 _udevadm_test-builtin(){
575     if (( CURRENT == 2 )); then
576     _arguments \
577         '--help[Print help text]' \
578         '*::builtins:(blkid btrfs hwdb input_id kmod path_id usb_id uaccess)'
579     elif  (( CURRENT == 3 )); then
580         _arguments \
581             '--help[Print help text]' \
582             '*::syspath:_files -P /sys -W /sys'
583     else
584         _arguments \
585             '--help[Print help text]'
586     fi
587 }
588
589 _udevadm_mounts(){
590   local dev_tmp dpath_tmp mp_tmp mline
591
592     tmp=( "${(@f)$(< /etc/mtab)}" )
593     dev_tmp=( "${(@)${(@)tmp%% *}:#none}" )
594     mp_tmp=( "${(@)${(@)tmp#* }%% *}" )
595
596   local MATCH
597   mp_tmp=("${(@q)mp_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}")
598   dpath_tmp=( "${(@Mq)dev_tmp:#/*}" )
599   dev_tmp=( "${(@q)dev_tmp:#/*}" )
600
601   _alternative \
602     'device-paths: device path:compadd -a dpath_tmp' \
603     'directories:mount point:compadd -a mp_tmp'
604 }
605
606
607 _udevadm_command(){
608     local -a _udevadm_cmds
609     _udevadm_cmds=(
610         'info:query sysfs or the udev database'
611         'trigger:request events from the kernel'
612         'settle:wait for the event queue to finish'
613         'control:control the udev daemon'
614         'monitor:listen to kernel and udev events'
615         'test:test an event run'
616         'test-builtin:test a built-in command'
617     )
618
619     if ((CURRENT == 1)); then
620         _describe -t commands 'udevadm commands' _udevadm_cmds
621     else
622         local curcontext="$curcontext"
623         cmd="${${_udevadm_cmds[(r)$words[1]:*]%%:*}}"
624         if (($#cmd)); then
625             if (( $+functions[_udevadm_$cmd] )); then
626                 _udevadm_$cmd
627             else
628                 _message "no options for $cmd"
629             fi
630         else
631             _message "no more options"
632         fi
633     fi
634 }
635
636 _ctls "$@"
637
638 #vim: set ft=zsh sw=4 ts=4 et