]> git.ipfire.org Git - thirdparty/systemd.git/blob - shell-completion/zsh/_udevadm
sd-boot+bootctl: invert order of entries w/o sort-key
[thirdparty/systemd.git] / shell-completion / zsh / _udevadm
1 #compdef udevadm
2 # SPDX-License-Identifier: LGPL-2.1-or-later
3
4 (( $+functions[_udevadm_info] )) ||
5 _udevadm_info(){
6 _arguments \
7 '--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)' \
8 '--path=[The devpath of the device to query.]:sys files:_files -P /sys/ -W /sys' \
9 '--name=[The name of the device node or a symlink to query]:device files:_files -P /dev/ -W /dev' \
10 '--root[Print absolute paths in name or symlink query.]' \
11 '--attribute-walk[Print all sysfs properties of the specified device that can be used in udev rules to match the specified device]' \
12 '--export[Print output as key/value pairs.]' \
13 '--export-prefix=[Add a prefix to the key name of exported values.]:prefix' \
14 '--device-id-of-file=[Print major/minor numbers of the underlying device, where the file lives on.]:files:_udevadm_mounts' \
15 '--export-db[Export the content of the udev database.]' \
16 '--cleanup-db[Cleanup the udev database.]' \
17 '--value[When showing properties, print only their values.]' \
18 '--property=[Show only properties by this name.]'
19 }
20
21 (( $+functions[_udevadm_trigger] )) ||
22 _udevadm_trigger(){
23 _arguments \
24 '--verbose[Print the list of devices which will be triggered.]' \
25 '--dry-run[Do not actually trigger the event.]' \
26 '--quiet[Suppress error logging in triggering events.]' \
27 '--type=[Trigger a specific type of devices.]:types:(devices subsystems failed)' \
28 '--action=[Type of event to be triggered.]:actions:(add change remove move online offline bind unbind)' \
29 '--subsystem-match=[Trigger events for devices which belong to a matching subsystem.]' \
30 '--subsystem-nomatch=[Do not trigger events for devices which belong to a matching subsystem.]' \
31 '--attr-match=attribute=[Trigger events for devices with a matching sysfs attribute.]' \
32 '--attr-nomatch=attribute=[Do not trigger events for devices with a matching sysfs attribute.]' \
33 '--property-match=[Trigger events for devices with a matching property value.]' \
34 '--tag-match=property[Trigger events for devices with a matching tag.]' \
35 '--sysname-match=[Trigger events for devices with a matching sys device name.]' \
36 '--parent-match=[Trigger events for all children of a given device.]' \
37 '--uuid[Print synthetic uevent UUID.]'
38 }
39
40 (( $+functions[_udevadm_settle] )) ||
41 _udevadm_settle(){
42 _arguments \
43 '--timeout=[Maximum number of seconds to wait for the event queue to become empty.]' \
44 '--seq-start=[Wait only for events after the given sequence number.]' \
45 '--seq-end=[Wait only for events before the given sequence number.]' \
46 '--exit-if-exists=[Stop waiting if file exists.]:files:_files' \
47 '--quiet[Do not print any output, like the remaining queue entries when reaching the timeout.]' \
48 '--help[Print help text.]'
49 }
50
51 (( $+functions[_udevadm_control] )) ||
52 _udevadm_control(){
53 _arguments \
54 '--exit[Signal and wait for systemd-udevd to exit.]' \
55 '--log-priority=[Set the internal log level of systemd-udevd.]:priorities:(err info debug)' \
56 '--stop-exec-queue[Signal systemd-udevd to stop executing new events. Incoming events will be queued.]' \
57 '--start-exec-queue[Signal systemd-udevd to enable the execution of events.]' \
58 '--reload[Signal systemd-udevd to reload the rules files and other databases like the kernel module index.]' \
59 '--property=[Set a global property for all events.]' \
60 '--children-max=[Set the maximum number of events.]' \
61 '--timeout=[The maximum number of seconds to wait for a reply from systemd-udevd.]' \
62 '--help[Print help text.]'
63 }
64
65 (( $+functions[_udevadm_monitor] )) ||
66 _udevadm_monitor(){
67 _arguments \
68 '--kernel[Print the kernel uevents.]' \
69 '--udev[Print the udev event after the rule processing.]' \
70 '--property[Also print the properties of the event.]' \
71 '--subsystem-match=[Filter events by subsystem/\[devtype\].]' \
72 '--tag-match=[Filter events by property.]' \
73 '--help[Print help text.]'
74 }
75
76 (( $+functions[_udevadm_test] )) ||
77 _udevadm_test(){
78 _arguments \
79 '--action=[The action string.]:actions:(add change remove move online offline bind unbind)' \
80 '--subsystem=[The subsystem string.]' \
81 '--help[Print help text.]' \
82 '*::devpath:_files -P /sys/ -W /sys'
83 }
84
85 (( $+functions[_udevadm_test-builtin] )) ||
86 _udevadm_test-builtin(){
87 if (( CURRENT == 2 )); then
88 _arguments \
89 '--action=[The action string.]:actions:(add change remove move online offline bind unbind)' \
90 '--help[Print help text]' \
91 '*::builtins:(blkid btrfs hwdb input_id net_id net_setup_link kmod path_id usb_id uaccess)'
92 elif (( CURRENT == 3 )); then
93 _arguments \
94 '--action=[The action string.]:actions:(add change remove move online offline bind unbind)' \
95 '--help[Print help text]' \
96 '*::syspath:_files -P /sys -W /sys'
97 else
98 _arguments \
99 '--action=[The action string.]:actions:(add change remove move online offline bind unbind)' \
100 '--help[Print help text]'
101 fi
102 }
103
104 (( $+functions[_udevadm_mounts] )) ||
105 _udevadm_mounts(){
106 local dev_tmp dpath_tmp mp_tmp mline
107
108 tmp=( "${(@f)$(< /proc/self/mounts)}" )
109 dev_tmp=( "${(@)${(@)tmp%% *}:#none}" )
110 mp_tmp=( "${(@)${(@)tmp#* }%% *}" )
111
112 local MATCH
113 mp_tmp=("${(@q)mp_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}")
114 dpath_tmp=( "${(@Mq)dev_tmp:#/*}" )
115 dev_tmp=( "${(@q)dev_tmp:#/*}" )
116
117 _alternative \
118 'device-paths: device path:compadd -a dpath_tmp' \
119 'directories:mount point:compadd -a mp_tmp'
120 }
121
122 (( $+functions[_udevadm_commands] )) ||
123 _udevadm_commands(){
124 local -a _udevadm_cmds
125 _udevadm_cmds=(
126 'info:query sysfs or the udev database'
127 'trigger:request events from the kernel'
128 'settle:wait for the event queue to finish'
129 'control:control the udev daemon'
130 'monitor:listen to kernel and udev events'
131 'test:test an event run'
132 'test-builtin:test a built-in command'
133 )
134
135 if ((CURRENT == 1)); then
136 _describe -t commands 'udevadm commands' _udevadm_cmds
137 else
138 local curcontext="$curcontext"
139 cmd="${${_udevadm_cmds[(r)$words[1]:*]%%:*}}"
140 if (($#cmd)); then
141 if (( $+functions[_udevadm_$cmd] )); then
142 _udevadm_$cmd
143 else
144 _message "no options for $cmd"
145 fi
146 else
147 _message "no more options"
148 fi
149 fi
150 }
151
152 _arguments \
153 '--debug[Print debug messages to stderr]' \
154 '--version[Print version number]' \
155 '--help[Print help text]' \
156 '*::udevadm commands:_udevadm_commands'