shell-completion: update for udevadm

This commit is contained in:
Yu Watanabe 2022-04-05 03:17:48 +09:00
parent e7e25c21c6
commit d90dbba7ec
2 changed files with 32 additions and 1 deletions

View file

@ -65,9 +65,10 @@ _udevadm() {
[TEST]='-a --action -N --resolve-names'
[TEST_BUILTIN]='-a --action'
[WAIT]='-t --timeout --initialized=no --removed --settle'
[LOCK]='-t --timeout -d --device -b --backing -p --print'
)
local verbs=(info trigger settle control monitor test-builtin test wait)
local verbs=(info trigger settle control monitor test-builtin test wait lock)
local builtins=(blkid btrfs hwdb input_id keyboard kmod net_id net_setup_link path_id usb_id uaccess)
for ((i=0; i < COMP_CWORD; i++)); do
@ -265,6 +266,24 @@ _udevadm() {
fi
;;
'lock')
if __contains_word "$prev" ${OPTS[LOCK]}; then
case $prev in
*)
comps=''
;;
esac
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
fi
if [[ $cur = -* ]]; then
comps="${OPTS[COMMON]} ${OPTS[LOCK]}"
else
comps=''
fi
;;
*)
comps=${VERBS[*]}
;;

View file

@ -115,6 +115,16 @@ _udevadm_wait(){
'*::devpath:_files -P /dev/ -W /dev'
}
(( $+functions[_udevadm_lock] )) ||
_udevadm_lock(){
_arguments \
'--timeout=[Maximum number of seconds to wait for the devices being locked.]' \
'--device=[Block device to lock.]' \
'--backing=[File whose backing block device to lock.]' \
'--print[Only show which block device the lock would be taken on.]' \
'--help[Print help text.]'
}
(( $+functions[_udevadm_mounts] )) ||
_udevadm_mounts(){
local dev_tmp dpath_tmp mp_tmp mline
@ -144,6 +154,8 @@ _udevadm_commands(){
'monitor:listen to kernel and udev events'
'test:test an event run'
'test-builtin:test a built-in command'
'wait:wait for devices or device symlinks being created'
'lock:lock a block device and run a comand'
)
if ((CURRENT == 1)); then