Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: update ethtool completion
- X-seq: zsh-workers 41724
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: update ethtool completion
- Date: Mon, 18 Sep 2017 09:21:57 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1505726393; bh=1dW3x+SXJ0cke+OROWCjQmY2Yr9ZzTijS1sYoJgbhlM=; h=From:To:Subject:Date:From:Subject; b=UX348F0LpnZOZSY98QHnYDaBaevmYQlnVTGZnIdn88/JcV/qsdAM9U6WAG6h4TILbk/NMB0BzKybfb2KbUYIFT1J+AAH3SUEdw4vlD+RbYMyx13JXHWEW0Rydn3GJAas06bGOUHX817WzBDZb01m1AIiLPOujRg42iBQ6454BQw07nquFpw2osnYMZyu1ZfKngbaA194NbcszKcLbQxaczaAn+qlqkQ6ppImfsZF3bnwCbWL0uOPk41kOu3Yq+Flh2ABQsdwlqKMu97mw5XKxfijFmTP7+ing8WBBimfm9yjvsNegQc3mbKz/l5XE8o2abRz8R39KyCVcDmfdFDzJg==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
This updates the ethtool completion up to version 4.11.
I'll also reindent the function when committing.
Oliver
diff --git a/Completion/Linux/Command/_ethtool b/Completion/Linux/Command/_ethtool
index 71f5ed3bf..9a92c0066 100644
--- a/Completion/Linux/Command/_ethtool
+++ b/Completion/Linux/Command/_ethtool
@@ -1,29 +1,86 @@
#compdef ethtool
-local -a expl cmds
+local curcontext="$curcontext"
+local -a state line expl cmds
+local -A opt_args
-if [[ $CURRENT -ge 4 ]]; then
+_arguments -C \
+ "1:interface:_net_interfaces" \
+ '*: :->args' \
+ + '(cmds)' \
+ '(1)'{-h,--help}'[display help information]' \
+ '(1)--version[display version information]' \
+ {-s,--change}'[allow changing some or all settings of the specified ethernet device]' \
+ {-a,--show-pause}'[query the specified ethernet device for pause parameter information]' \
+ {-A,--pause}'[change the pause parameters of the specified ethernet device]' \
+ {-c,--show-coalesce}'[query the specified ethernet device for coalescing information]' \
+ {-C,--coalesce}'[change the coalescing settings of the specified ethernet device]' \
+ {-g,--show-ring}'[query the specified ethernet device for RX/TX ring parameter information]' \
+ {-G,--set-ring}'[change the RX/TX ring parameters of the specified ethernet device]' \
+ {-k,--show-features,--show-offload}'[query the specified ethernet device for offload information]' \
+ {-K,--features,--offload}'[change the offload parameters of the specified ethernet device]' \
+ {-i,--driver}'[query the specified ethernet device for associated driver information]' \
+ {-d,--register-dump}'[retrieve and prints a register dump for the specified ethernet device]' \
+ {-e,--eeprom-dump}'[retrieve and prints an EEPROM dump for the specified ethernet device]' \
+ {-E,--change-eeprom}'[change EEPROM byte for the specified ethernet device]' \
+ {-r,--negotiate}'[restart auto-negotiation on the specified ethernet device]' \
+ {-p,--identify}'[initiate adapter-specific action intended to identify the adapter by sight]' \
+ {-t,--test}'[execute adapter selftest on the specified ethernet device]' \
+ {-S,--statistics}'[query specified ethernet device for NIC- and driver-specific statistics]' \
+ '--phy-statistics[show phy statistics]' \
+ {-n,--show-nfc,-u,--show-ntuple}'[retrieve receive network flow classification options or rules]' \
+ {-N,--config-nfc,-U,--config-ntuple}'[configure receive network flow classification options or rules]' \
+ {-T,--show-time-stamping}"[show device's time stamping capabilities]" \
+ {-x,--show-rxfh-indir,--show-rxfh}'[show Rx flow hash indirection table and/or RSS hash key]' \
+ {-X,--set-rxfh-indir,--rxfh}'[set Rx flow hash indirection table and/or RSS hash key]' \
+ {-f,--flash}'[flash firmware image from the specified file]' \
+ {-P,--show-permaddr}'[show permanent hardware address]' \
+ {-w,--get-dump}'[get dump flag, data]' \
+ {-W,--set-dump}'[set device dump flag]' \
+ {-l,--show-channels}'[query channels]' \
+ {-L,--set-channels}'[set channels]' \
+ '--show-priv-flags[query private flags]' \
+ '--set-priv-flags[set private flags]' \
+ {-m,--dump-module-eeprom,--module-info}'[show module EEPROM information]' \
+ '--show-eee[show EEE settings]' \
+ '--set-eee[set EEE settings]' \
+ '--set-phy-tunable[set PHY tunable]' \
+ '--get-phy-tunable[get PHY tunable]' && return
+
+if [[ -n $state ]]; then
case $words[CURRENT-1] in
rx|tx)
- [[ $words[2] = '-G' ]] && _message -e n 'number of ring entries' || _wanted -x onoff expl 'enabled' compadd off on
+ if (( $+opt_args[cmds--G] + $+opt_args[cmds---set-ring] )); then
+ _message -e numbers 'number of ring entries'
+ elif (( $+opt_args[cmds--L] + $+opt_args[cmds---set-channels] )); then
+ _message -e numbers 'number of channels'
+ else
+ _wanted onoff expl 'enabled' compadd off on
+ fi
;;
- autoneg|adaptive-rx|adaptive-tx|raw|hex|sg|tso|ufo|gso)
- _wanted -x onoff expl 'enabled' compadd off on
+ autoneg|adaptive-[rt]x|raw|hex|sg|tso|ufo|gso|lro|eee|tx-lpi|downshift)
+ _wanted onoff expl 'enabled' compadd off on
;;
- rx-usecs|rx-frames|rx-usecs-irq|rx-frames-irq|tx-usecs|tx-frames|tx-usecs-irq|tx-frames-irq|stats-block-usecs|pkt-rate-low|rx-usecs-low|rx-frames-low|tx-usecs-low|tx-frames-low|pkt-rate-high|rx-usecs-high|rx-frames-high|tx-usecs-high|tx-frames-high|sample-interval|rx-mini|rx-jumbo|offset|length|magic|value|phyad|msglvl)
- _message -e n 'number'
+ rx-usecs|rx-frames|rx-usecs-irq|rx-frames-irq|tx-usecs|tx-frames) ;&
+ tx-usecs-irq|tx-frames-irq|stats-block-usecs|pkt-rate-low|rx-usecs-low) ;&
+ rx-frames-low|tx-usecs-low|tx-frames-low|pkt-rate-high|rx-usecs-high) ;&
+ rx-frames-high|tx-usecs-high|tx-frames-high|sample-interval|rx-mini) ;&
+ rx-jumbo|offset|length|magic|value|phyad|proto|tos|tclass|l4proto|src-port) ;&
+ dst-port|spi|l4data|vlan-etype|vlan|user-def|action|vf|queue|loc|delete) ;&
+ other|combined|tx-timer|count)
+ _message -e numbers 'number'
;;
speed)
_wanted -x speed expl 'speed' compadd 10 100 1000
;;
duplex)
- _wanted -x duplex expl 'duplex mode' compadd half full
+ _wanted duplex expl 'duplex mode' compadd half full
;;
port)
- _wanted -x port expl 'device port' compadd tp aui bnc mii
+ _wanted port expl 'device port' compadd tp aui bnc mii fibre
;;
advertise)
- _values 'hexidecimal value (or a combination of the following)' \
+ _values 'hexadecimal value (or a combination of the following)' \
'0x001[10 half]' \
'0x002[10 full]' \
'0x004[100 half]' \
@@ -35,10 +92,10 @@ if [[ $CURRENT -ge 4 ]]; then
'0x03F[auto]'
;;
xcvr)
- _wanted -x xcvr expl 'transceiver type' compadd internal external
+ _wanted xcvr expl 'transceiver type' compadd internal external
;;
wol)
- _values -s '' 'Wake-on-LAN options' \
+ _values -s '' 'Wake-on-LAN option' \
'(d)p[wake on phy activity]' \
'(d)u[wake on unicast messages]' \
'(d)m[wake on multicast messages]' \
@@ -51,75 +108,88 @@ if [[ $CURRENT -ge 4 ]]; then
sopass)
_message -e secureon 'password - 6 bytes in ethernet MAC hex format (xx:yy:zz:aa:bb:cc)'
;;
- file)
- _wanted files expl 'raw register dump files' _files
+ data|file)
+ _wanted files expl 'file' _files
+ ;;
+ rx-flow-hash)
+ _wanted flow-types expl 'flow type' compadd {tcp,udp,ah,esp,sctp}{4,6}
+ ;;
+ rule)
+ _message -e ids 'rule id'
+ ;;
+ flow-type)
+ _wanted flow-types expl 'flow type' compadd ether {tcp,udp,ah,esp,sctp}{4,6}
+ ;;
+ src|src-ip|dst|dst-ip|dst-mac)
+ _message -e addresses address
+ ;;
+ m)
+ _message -e masks mask
+ ;;
+ hkey)
+ _message -e keys expl 'hash key'
+ ;;
+ hfunc)
+ _message -e functions expl 'hash function'
;;
*)
case $words[2] in
-A|--pause)
- _values -S ' ' -w 'pause options' \
+ _values -S ' ' -w 'pause parameter' \
'autoneg[specify if pause autonegotiation is enabled]' \
'rx[specify if RX pause is enabled]' \
'tx[specify if TX pause is enabled]'
;;
-C|--coalesce)
- _values -S ' ' -w 'coalescing settings' \
- 'adaptive-rx' 'adaptive-tx' \
- 'rx-usecs' 'rx-frames' 'rx-usecs-irq' 'rx-frames-irq' \
- 'tx-usecs' 'tx-frames' 'tx-usecs-irq' 'tx-frames-irq' \
- 'stats-block-usecs' \
- 'pkt-rate-low' \
- 'rx-usecs-low' 'rx-frames-low' \
- 'tx-usecs-low' 'tx-frames-low' \
- 'pkt-rate-high' \
- 'rx-usecs-high' 'rx-frames-high' \
- 'tx-usecs-high' 'tx-frames-high' \
- 'sample-interval'
+ _wanted settings expl 'coalescing setting' compadd -F line -M 'r:|-=* r:|=*' - \
+ adaptive-{r,t}x {r,t}x-{usecs,frames}{,-irq,-high,-low} \
+ stats-block-usecs pkt-rate-{low,high} sample-interval
;;
-G|--set-ring)
- _values -S ' ' -w 'ring parameters' \
+ _values -S ' ' -w 'ring parameter' \
'rx[change number of ring entries for the RX ring]' \
'rx-mini[change number of ring entries for the RX Mini ring]' \
'rx-jumbo[change number of ring entries for the RX Jumbo ring]' \
'tx[change number of ring entries for the TX ring]'
;;
-d|--register-dump)
- _values -S ' ' -w 'register dump options' \
+ _values -S ' ' -w 'option' \
'hex[dump hex register data]' \
'raw[dump raw register data]' \
'file[use contents from file rather than device]'
;;
-e|--eeprom-dump)
- _values -S ' ' -w 'EEPROM dump options' \
+ _values -S ' ' -w 'option' \
'raw[dump raw EEPROM data]' \
- 'offset[dump certain portions of the EEPROM]' \
- 'length[dump certain portions of the EEPROM]'
+ 'offset' 'length'
;;
-E|--change-eeprom)
- _values -S ' ' -w 'EEPROM values' \
+ _values -S ' ' -w 'option' \
'magic[device-specific key]' \
- 'offset[select byte]' \
+ 'offset' 'length'
'value[new value]'
;;
- -K|--offload)
- _values -S ' ' -w 'offload options' \
- 'rx[specify if RX checksumming is enabled]' \
- 'tx[specify if TX checksumming is enabled]' \
- 'sg[specify if scatter-gather is enabled]' \
- 'tso[specify if TCP segmentation offload is enabled]' \
- 'ufo[specify if UDP segmentation offload is enabled]' \
- 'gso[specify if generic segmentation offload is enabled]'
+ -K|--features|--offload)
+ if (( CURRENT % 2 )); then
+ _wanted values expl enable compadd on off
+ else
+ _wanted features expl feature compadd -F line - \
+ ${${${${(f)"$(_call_program features $words[1] -k $line[1])"}%%:*}#$'\t'}[2,-1]} \
+ rx tx sg tso ufo gso gro rxvlan txvlan ntuple rxhash
+ fi
;;
-p|--identify)
- [[ $CURRENT -eq 4 ]] && _message -e length 'seconds'
+ (( CURRENT = 4 )) && _message -e length 'duration (seconds)'
;;
-t|--test)
- _values -S ' ' -w 'selftest option' \
+ _values -S ' ' -w 'test mode' \
'(online)offline:perform full set of tests possibly causing normal operation interruption (default)]' \
- '(offline)online:perform limited set of tests do not interrupting normal adapter operation]'
+ '(offline)online:perform limited set of tests without interrupting normal adapter operation]' \
+ 'external_lb[perform full set of tests plus external-loopback test]'
;;
-s|--change)
- _values -S ' ' -w 'change setting' \
+ if (( ! $words[(I)msglvl] )); then
+ _values -S ' ' -w 'generic option' \
'speed[set speed in Mb/s]' \
'duplex[set full or half duplex mode]' \
'port[select device port]' \
@@ -130,35 +200,72 @@ if [[ $CURRENT -ge 4 ]]; then
'wol[set Wake-on-LAN options]' \
'sopass[set the SecureOn(tm) password]' \
'msglvl[set the driver message level]'
+ elif (( (CURRENT - $words[(I)msglvl]) % 2 )); then
+ [[ -prefix [^0-9]## ]] || _message -e numbers number
+ _wanted flags expl 'message type flag' compadd drv probe link timer if{down,up} rx_{err,status} tx_{err,queued,done} intr pktdata hw wol
+ else
+ _wanted onoff expl 'enabled' compadd off on
+ fi
;;
+ -n|-u|--show-nfc|--show-ntuple)
+ _wanted options expl option compadd -F line - rx-flow-hash rule
+ ;;
+ -N|-U|--config-nfc|--config-ntuple)
+ if [[ $words[CURRENT-2] = rx-flow-hash ]]; then
+ _values -S ' ' 'rx packet hash' \
+ 'm[layer 2 destination address]' \
+ 'v[VLAN tag]' \
+ 't[layer 3 protocol field]' \
+ 's[IP source address]' \
+ 'd[IP destination address]' \
+ 'f[bytes 0 and 1 of the Layer 4 header]' \
+ 'n[bytes 2 and 3 of the Layer 4 header]' \
+ 'r[discard all packets of this flow type]'
+ else
+ _wanted options expl option compadd -F line - rx-flow-hash flow-type delete \
+ src dst proto src-ip dst-ip tos m tclass l4proto src-port dst-port spi l4data vlan-etype vlan user-def dst-mac action vf queue loc
+ fi
+ ;;
+ -X|--set-rxfh-indir|--rxfh)
+ _values -S ' ' -w 'option' \
+ '(weight default)equal' \
+ '(equal default)weight' \
+ '(equal weight)default' \
+ hkey hfunc
+ ;;
+ -f|--flash)
+ if (( CURRENT = 4 )); then
+ _files
+ else
+ _message -e regions region
+ fi
+ ;;
+ -w|--get-dump)
+ _wanted options expl option compadd data
+ ;;
+ -L|--set-channels)
+ _wanted options expl option compadd -F line - rx tx other combined
+ ;;
+ --set-priv-flags)
+ if (( CURRENT % 2 )); then
+ _wanted values expl enable compadd on off
+ else
+ _message -e flags 'private flag'
+ fi
+ ;;
+ -m|--dump-module-eeprom|--module-info)
+ _wanted options expl option compadd -F line - raw hex offset length
+ ;;
+ --set-eee)
+ _wanted behaviours expl behaviour compadd -F line - eee advertise tx-lpi tx-timer
+ ;;
+ --set-phy-tunable)
+ _wanted options expl tunable compadd -F line - downshift count
+ ;;
+ --get-phy-tunable)
+ _wanted options expl tunable compadd downshift
+ ;;
esac
;;
esac
fi
-
-cmds=(-h -a -A -c -C -g -G -i -d -e -E -k -K -p -r -S -t -s
- --help --show-pause --pause --show-coalesce --coalesce --show-ring
- --set-ring --driver --register-dump --eeprom-dump --change-eeprom
- --show-offload --offload --identify --negotiate --statistics --test --change)
-
-_arguments \
- "($cmds)1:interface:_net_interfaces" \
- "($cmds 1)"{-h,--help}'[shows a short help message]' \
- "($cmds)"{-a,--show-pause}'[queries the specified ethernet device for pause parameter information]' \
- "($cmds)"{-A,--pause}'[change the pause parameters of the specified ethernet device]' \
- "($cmds)"{-c,--show-coalesce}'[queries the specified ethernet device for coalescing information]' \
- "($cmds)"{-C,--coalesce}'[change the coalescing settings of the specified ethernet device]' \
- "($cmds)"{-g,--show-ring}'[queries the specified ethernet device for RX/TX ring parameter information]' \
- "($cmds)"{-G,--set-ring}'[change the RX/TX ring parameters of the specified ethernet device]' \
- "($cmds)"{-i,--driver}'[queries the specified ethernet device for associated driver information]' \
- "($cmds)"{-d,--register-dump}'[retrieves and prints a register dump for the specified ethernet device]' \
- "($cmds)"{-e,--eeprom-dump}'[retrieves and prints an EEPROM dump for the specified ethernet device]' \
- "($cmds)"{-E,--change-eeprom}'[changes EEPROM byte for the specified ethernet device]' \
- "($cmds)"{-k,--show-offload}'[queries the specified ethernet device for offload information]' \
- "($cmds)"{-K,--offload}'[change the offload parameters of the specified ethernet device]' \
- "($cmds)"{-p,--identify}'[initiates adapter-specific action intended to identify the adapter by sight]' \
- "($cmds)"{-r,--negotiate}'[restarts auto-negotiation on the specified ethernet device]' \
- "($cmds)"{-S,--statistics}'[queries the specified ethernet device for NIC- and driver-specific statistics]' \
- "($cmds)"{-t,--test}'[executes adapter selftest on the specified ethernet device]' \
- "($cmds)"{-s,--change}'[allows changing some or all settings of the specified ethernet device]' \
- '*:' && ret=0
.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author