@@ -34,68 +34,61 @@ _udevadm() {
3434 local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
3535 local OPTS=' -h --help --version --debug'
3636
37- local -A VERBS=(
38- [INFO]=' info'
39- [TRIGGER]=' trigger'
40- [SETTLE]=' settle'
41- [CONTROL]=' control'
42- [MONITOR]=' monitor'
43- [HWDB]=' hwdb'
44- [TESTBUILTIN]=' test-builtin'
45- [TEST]=' test'
46- )
37+ local verbs=(info trigger settle control monitor hwdb test-builtin test)
4738
48- for (( i= 0 ; $ i <= $ COMP_CWORD ; i++ )) ; do
49- if __contains_word " ${COMP_WORDS[i]} " ${VERBS[*]} &&
39+ for (( i= 0 ; i <= COMP_CWORD; i++ )) ; do
40+ if __contains_word " ${COMP_WORDS[i]} " " ${verbs[@]} " &&
5041 ! __contains_word " ${COMP_WORDS[i-1]} " ${OPTS[ARG]} ; then
5142 verb=${COMP_WORDS[i]}
5243 break
5344 fi
5445 done
5546
56- if [[ -z $verb && $cur = - * ]]; then
57- COMPREPLY=( $( compgen -W ' ${OPTS[*]}' -- " $cur " ) )
47+ if [[ -z $verb ]]; then
48+ COMPREPLY=( $( compgen -W ' ${OPTS[*]} ${verbs[*]} ' -- " $cur " ) )
5849 return 0
5950 fi
6051
61- if [[ -z $verb ]]; then
62- comps=${VERBS[*]}
63-
64- elif __contains_word " $verb " ${VERBS[INFO]} ; then
65- if [[ $cur = -* ]]; then
66- comps=' --help --query= --path= --name= --root --attribute-walk --export-db --cleanup-db'
67- else
68- comps=$( __get_all_sysdevs )
69- fi
70-
71- elif __contains_word " $verb " ${VERBS[TRIGGER]} ; then
72- comps=' --help --verbose --dry-run --type= --action= --subsystem-match=
73- --subsystem-nomatch= --attr-match= --attr-nomatch= --property-match=
74- --tag-match= --sysname-match= --parent-match='
75-
76- elif __contains_word " $verb " ${VERBS[SETTLE]} ; then
77- comps=' --help --timeout= --seq-start= --seq-end= --exit-if-exists= --quiet'
78-
79- elif __contains_word " $verb " ${VERBS[CONTROL]} ; then
80- comps=' --help --exit --log-priority= --stop-exec-queue --start-exec-queue
81- --reload --property= --children-max= --timeout='
82-
83- elif __contains_word " $verb " ${VERBS[MONITOR]} ; then
84- comps=' --help --kernel --udev --property --subsystem-match= --tag-match='
85-
86- elif __contains_word " $verb " ${VERBS[HWDB]} ; then
87- comps=' --help --update --test='
88-
89- elif __contains_word " $verb " ${VERBS[TEST]} ; then
90- if [[ $cur = -* ]]; then
91- comps=' --help --action='
92- else
93- comps=$( __get_all_sysdevs )
94- fi
95-
96- elif __contains_word " $verb " ${VERBS[TESTBUILTIN]} ; then
97- comps=' blkid btrfs hwdb input_id keyboard kmod net_id path_id usb_id uaccess'
98- fi
52+ case $verb in
53+ ' info' )
54+ if [[ $cur = -* ]]; then
55+ comps=' --help --query= --path= --name= --root --attribute-walk --export-db --cleanup-db'
56+ else
57+ comps=$( __get_all_sysdevs )
58+ fi
59+ ;;
60+ ' trigger' )
61+ comps=' --help --verbose --dry-run --type= --action= --subsystem-match=
62+ --subsystem-nomatch= --attr-match= --attr-nomatch= --property-match=
63+ --tag-match= --sysname-match= --parent-match='
64+ ;;
65+ ' settle' )
66+ comps=' --help --timeout= --seq-start= --seq-end= --exit-if-exists= --quiet'
67+ ;;
68+ ' control' )
69+ comps=' --help --exit --log-priority= --stop-exec-queue --start-exec-queue
70+ --reload --property= --children-max= --timeout='
71+ ;;
72+ ' monitor' )
73+ comps=' --help --kernel --udev --property --subsystem-match= --tag-match='
74+ ;;
75+ ' hwdb' )
76+ comps=' --help --update --test='
77+ ;;
78+ ' test' )
79+ if [[ $cur = -* ]]; then
80+ comps=' --help --action='
81+ else
82+ comps=$( __get_all_sysdevs )
83+ fi
84+ ;;
85+ ' test-builtin' )
86+ comps=' blkid btrfs hwdb input_id keyboard kmod net_id path_id usb_id uaccess'
87+ ;;
88+ * )
89+ comps=${VERBS[*]}
90+ ;;
91+ esac
9992
10093 COMPREPLY=( $( compgen -W ' $comps' -- " $cur " ) )
10194 return 0
0 commit comments