Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: usbconfig completion
- X-seq: zsh-workers 46106
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: usbconfig completion
- Date: Tue, 23 Jun 2020 23:59:30 +0200
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <95445-1592949570.280834.ref@dFGk.KvIW._mS9>
- Sender: zsh-workers@xxxxxxx
This adds completion for the FreeBSD usbconfig utility. I had made a
note to fix it for Dragonfly but am posting it without rather than have
it sit any longer in my own branch.
Oliver
diff --git a/Completion/BSD/Command/_usbconfig b/Completion/BSD/Command/_usbconfig
new file mode 100644
index 000000000..e7da8132c
--- /dev/null
+++ b/Completion/BSD/Command/_usbconfig
@@ -0,0 +1,63 @@
+#compdef usbconfig
+
+local curcontext="$curcontext" i ret=1
+local -a state line expl devices ids partial args
+
+_arguments -C \
+ '(-d)-u[limit device range to given USBUS unit]:bus:->buses' \
+ '(-d)-a[limit device range to given USB device index]:address:->addresses' \
+ '(-a -u)-d[limit device range to given unit and address]:device:->devices' \
+ '-i[specify interface index]:interface index' \
+ '(- 1)-h[display usage information]' \
+ '(-)1:command:compadd -M "r:|_=* r:|=*"
+ set_config set_alt set_template get_template add_dev_quirk_vplh
+ remove_dev_quirk_vplh add_quirk remove_quirk detach_kernel_driver
+ dump_quirk_names dump_device_quirks dump_all_desc dump_device_desc
+ dump_curr_config_desc dump_all_config_desc dump_string dump_info show_ifdrv
+ suspend resume power_off power_save power_on reset list do_request' \
+ '*::: := ->args' && ret=0
+
+case $state in
+ buses) partial=( ${(kv)=opt_args[(i)-a]:--a 1} ) i=1 ;|
+ addresses) partial=( ${(kv)opt_args[(i)-u]} ) i=2 ;&
+ buses)
+ devices=( ${${(f)"$(_call_program usb-devices usbconfig $partial list)"}:#No device*} )
+ ids=( ${${(MSI.i.)devices##[^0-9]<->}#?} )
+ _wanted usb-$state expl ${state%es} compadd -ld devices -o numeric -a ids && ret=0
+ ;;
+ devices)
+ devices=( ${${${(f)"$(_call_program usb-devices usbconfig list)"}/: /:}:#No device*} )
+ if (( $#devices )); then
+ _describe -t usb-devices device devices -M 'B:=ugen' && ret=0
+ else
+ _message -e usb-devices device
+ fi
+ ;;
+ args)
+ curcontext="${curcontext%:*}-$line[1]:"
+ case $line[1] in
+ set_config) args=( '1:cfg index' ) ;;
+ set_alt) args=( '1:alt index' ) ;;
+ set_template) args=( '1:template (see usb_template(4))' ) ;;
+ (add|remove)_dev_quirk_vplh) args=( -C
+ ':vendor id' ':product id' ':low revision'
+ ':high revision' ':quirk:->quirks'
+ ) ;;
+ (add|remove)_quirk) args=( -C '1:quirk:->quirks' ) ;;
+ dump_string) args=( '1:index' ) ;;
+ do_request) args=( :bmReqTyp :bReq :wVal :wIdx :wLen '*:data' ) ;;
+ esac
+ if (( $#args )); then
+ _arguments $args && ret=0
+ else
+ _message 'no more arguments'
+ fi
+ if [[ $state = quirks ]]; then
+ _wanted quirks expl quirk compadd \
+ -M 'm:{:lower:}={:upper:} r:|_=* r:|=* b:=UQ_' \
+ ${${(f)"$(_call_program quirks usbconfig dump_quirk_names)"}:#*list of*} && ret=0
+ fi
+ ;;
+esac
+
+return ret
Messages sorted by:
Reverse Date,
Date,
Thread,
Author