]> git.ipfire.org Git - thirdparty/systemd.git/blob - shell-completion/zsh/_udevadm
Merge pull request #22791 from keszybz/bootctl-invert-order
[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:(all 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 '--initialized-match[Trigger events for devices that are already initialized.]' \
38 '--initialized-nomatch[Trigger events for devices that are not initialized yet.]' \
39 '--uuid[Print synthetic uevent UUID.]' \
40 '--prioritized-subsystem=[Trigger events for devices which belong to a matching subsystem earlier.]'
41 }
42
43 (( $+functions[_udevadm_settle] )) ||
44 _udevadm_settle(){
45 _arguments \
46 '--timeout=[Maximum number of seconds to wait for the event queue to become empty.]' \
47 '--seq-start=[Wait only for events after the given sequence number.]' \
48 '--seq-end=[Wait only for events before the given sequence number.]' \
49 '--exit-if-exists=[Stop waiting if file exists.]:files:_files' \
50 '--quiet[Do not print any output, like the remaining queue entries when reaching the timeout.]' \
51 '--help[Print help text.]'
52 }
53
54 (( $+functions[_udevadm_control] )) ||
55 _udevadm_control(){
56 _arguments \
57 '--exit[Signal and wait for systemd-udevd to exit.]' \
58 '--log-priority=[Set the internal log level of systemd-udevd.]:priorities:(err info debug)' \
59 '--stop-exec-queue[Signal systemd-udevd to stop executing new events. Incoming events will be queued.]' \
60 '--start-exec-queue[Signal systemd-udevd to enable the execution of events.]' \
61 '--reload[Signal systemd-udevd to reload the rules files and other databases like the kernel module index.]' \
62 '--property=[Set a global property for all events.]' \
63 '--children-max=[Set the maximum number of events.]' \
64 '--timeout=[The maximum number of seconds to wait for a reply from systemd-udevd.]' \
65 '--help[Print help text.]'
66 }
67
68 (( $+functions[_udevadm_monitor] )) ||
69 _udevadm_monitor(){
70 _arguments \
71 '--kernel[Print the kernel uevents.]' \
72 '--udev[Print the udev event after the rule processing.]' \
73 '--property[Also print the properties of the event.]' \
74 '--subsystem-match=[Filter events by subsystem/\[devtype\].]' \
75 '--tag-match=[Filter events by property.]' \
76 '--help[Print help text.]'
77 }
78
79 (( $+functions[_udevadm_test] )) ||
80 _udevadm_test(){
81 _arguments \
82 '--action=[The action string.]:actions:(add change remove move online offline bind unbind)' \
83 '--subsystem=[The subsystem string.]' \
84 '--help[Print help text.]' \
85 '*::devpath:_files -P /sys/ -W /sys'
86 }
87
88 (( $+functions[_udevadm_test-builtin] )) ||
89 _udevadm_test-builtin(){
90 if (( CURRENT == 2 )); then
91 _arguments \
92 '--action=[The action string.]:actions:(add change remove move online offline bind unbind)' \
93 '--help[Print help text]' \
94 '*::builtins:(blkid btrfs hwdb input_id net_id net_setup_link kmod path_id usb_id uaccess)'
95 elif (( CURRENT == 3 )); then
96 _arguments \
97 '--action=[The action string.]:actions:(add change remove move online offline bind unbind)' \
98 '--help[Print help text]' \
99 '*::syspath:_files -P /sys -W /sys'
100 else
101 _arguments \
102 '--action=[The action string.]:actions:(add change remove move online offline bind unbind)' \
103 '--help[Print help text]'
104 fi
105 }
106
107 (( $+functions[_udevadm_mounts] )) ||
108 _udevadm_mounts(){
109 local dev_tmp dpath_tmp mp_tmp mline
110
111 tmp=( "${(@f)$(< /proc/self/mounts)}" )
112 dev_tmp=( "${(@)${(@)tmp%% *}:#none}" )
113 mp_tmp=( "${(@)${(@)tmp#* }%% *}" )
114
115 local MATCH
116 mp_tmp=("${(@q)mp_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}")
117 dpath_tmp=( "${(@Mq)dev_tmp:#/*}" )
118 dev_tmp=( "${(@q)dev_tmp:#/*}" )
119
120 _alternative \
121 'device-paths: device path:compadd -a dpath_tmp' \
122 'directories:mount point:compadd -a mp_tmp'
123 }
124
125 (( $+functions[_udevadm_commands] )) ||
126 _udevadm_commands(){
127 local -a _udevadm_cmds
128 _udevadm_cmds=(
129 'info:query sysfs or the udev database'
130 'trigger:request events from the kernel'
131 'settle:wait for the event queue to finish'
132 'control:control the udev daemon'
133 'monitor:listen to kernel and udev events'
134 'test:test an event run'
135 'test-builtin:test a built-in command'
136 )
137
138 if ((CURRENT == 1)); then
139 _describe -t commands 'udevadm commands' _udevadm_cmds
140 else
141 local curcontext="$curcontext"
142 cmd="${${_udevadm_cmds[(r)$words[1]:*]%%:*}}"
143 if (($#cmd)); then
144 if (( $+functions[_udevadm_$cmd] )); then
145 _udevadm_$cmd
146 else
147 _message "no options for $cmd"
148 fi
149 else
150 _message "no more options"
151 fi
152 fi
153 }
154
155 _arguments \
156 '--debug[Print debug messages to stderr]' \
157 '--version[Print version number]' \
158 '--help[Print help text]' \
159 '*::udevadm commands:_udevadm_commands'