zsh-users
 help / color / mirror / code / Atom feed
* new completions for iftop and tcpdump
@ 2008-05-29 12:30 Tomasz Pala
  2008-06-23 17:09 ` completion for ipset Tomasz Pala
  0 siblings, 1 reply; 9+ messages in thread
From: Tomasz Pala @ 2008-05-29 12:30 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 431 bytes --]

Hi,

I've send this email to zsh-workes 6 days ago and got no reply, so I
resend it here. Maybe someone improoves these completions enough to be
included into zsh.

------------------

Hello,

I've written some completion for iftop and tcpdump commands - see
attachements. However there's still lacking one for Berkeley Packet
Filter, both completions will benefit much if someone writes it.

-- 
Tomasz Pala <gotar@pld-linux.org>

[-- Attachment #2: _iftop --]
[-- Type: text/plain, Size: 665 bytes --]

#compdef iftop

_interfaces () {
	_wanted interfaces expl 'network interface' \
		_net_interfaces
	_values "Pseudo-device that captures on all interfaces" "any"
}

_arguments \
  '(-h -n -N -p -b -B -P -i -f -F -c)'-h'[print a summary of usage]' \
  -n"[don't do hostname lookups]" \
  -N"[don't resolve port number to service names]" \
  -p'[run in promiscuous mode]' \
  -P'[turn on port display]' \
  -b"[don't display bar graphs of traffic]" \
  -B'[display bandwidth rates in bytes/sec rather than bits/sec]' \
  -i'[interface]:network interface:_interfaces' \
  -f'[filter]:BPF filter' \
  -F'[net/mask]:network/mask' \
  -c'[config file]:config file:_files'

[-- Attachment #3: _tcpdump --]
[-- Type: text/plain, Size: 4299 bytes --]

#compdef tcpdump

typeset -A opt_args

_interfaces () {
	_wanted interfaces expl 'network interface' \
		_net_interfaces
	_values "Pseudo-device that captures on all interfaces" "any"
}

_esp_secrets () {
	_values -S : 'ESP algorithm' \
		'des-cbc:secret' \
		'3des-cbc:secret' \
		'blowfish-cbc:secret' \
		'rc3-cbc:secret' \
		'cast128-cbc:secret' \
		none
}

_packet_types () {
	_values 'Packets type' \
		'aodv[Ad-hoc On-demand Distance Vector protocol]' \
		'cnfp[Cisco NetFlow protocol]' \
		'rpc[Remote Procedure Call]' \
		'rtp[Real-Time  Applications  protocol]' \
		'rtcp[Real-Time Applications control protocol]' \
		'snmp[Simple Network Management Protocol]' \
		'tftp[Trivial File Transfer Protocol]' \
		'vat[Visual Audio Tool]' \
		'wb[distributed White Board]'
}

_data_link_types () {
	if (( $+opt_args[-i] )); then
		vals=( ${${${(s:  :)"$(_call_program data-link-types tcpdump -L -i $opt_args[-i] 2>&1)"}[2,-1]}/ /:} )
		_describe -t data-link-types "data link types ($opt_args[-i])" vals && ret=0
	else
		_values "Data link types (general)" \
			"EN10MB" \
			"LINUX_SLL"
	fi
}

_bpf_filter () {
}

_arguments \
  '()-A[Print each packet in ASCII]' \
  -c'[Exit after receiving specified number of packets]:number of packets' \
  -C'[Specify output file size in MB (10e6 bytes)]:output file size' \
  '(-ddd)-d[Dump the compiled packet-matching code in a human readable form]' \
  '(-ddd)-dd[Dump packet-matching code as a C program fragment]' \
  '(-d -dd)-ddd[Dump packet-matching code as decimal numbers (preceded with a count)]' \
  '(-A -c -C -d -dd -ddd -e -E -f -F -i -l -L -m -M -n -N -O -p -q -R -r -S -s -T -t -tt -ttt -tttt -u -U -v -vv -vvv -w -W -x -xx -X -XX -y -Z *)'-D'[Print the list of the network interfaces available on the system]' \
  -e'[Print the link-level header on each dump line]' \
  -E"[Decrypting IPsec ESP packets]:spi@ipaddr::algo\:secret:_esp_secrets" \
  -f"[Print 'foreign' IPv4 addresses numerically]" \
  -F'[input file for the filter expression]:filter expression file:_files' \
  -i'[Interface]:interface:_interfaces' \
  -l'[Make stdout line buffered]' \
  '(-A -c -C -d -dd -ddd -e -E -f -F -l -D -m -M -n -N -O -p -q -R -r -S -s -T -t -tt -ttt -tttt -u -U -v -vv -vvv -w -W -x -xx -X -XX -y -Z *)'-L'[List the known data link types for the interface]' \
  '*-m[Load SMI MIB module definitions]:SMI MIB module definitions:_files' \
  -M'[shared secret for validating the digests in TCP segments with the TCP-MD5 option]:secret' \
  -n"[Don't convert addresses to names]" \
  -N"[Don't print domain name qualification of host names]" \
  -O"[Don't run the packet-matching code optimizer]" \
  -p"[Don't put the interface into promiscuous mode]" \
  -q'[Quick (quiet?) output]' \
  -R'[Assume ESP/AH packets to be based on old specification (RFC1825 to RFC1829)]' \
  -r'[Read packets from file]:input file:_files' \
  -S'[Print absolute TCP sequence numbers]' \
  -s'[Specify number of bytes of data to snarf from each packet]:number of bytes to snap' \
  -T'[Interpret captured packets as specified type]:packet type:_packet_types' \
  "(-tttt)-t[Don't print a timestamp on each dump line]" \
  '(-ttt -tttt)-tt[Print an unformatted timestamp on each dump line]' \
  '(-tt -tttt)-ttt[Print a delta (in micro-seconds) between current and previous line on each dump line]' \
  '(-t -tt -ttt)-tttt[Print a timestamp in default format proceeded by date on each dump line]' \
  -u'[Print undecoded NFS handles]' \
  -U'[Make output packet-buffered when saving to file (-w)]' \
  '(-vvv)-v[slightly more verbose output]' \
  '(-vvv)-vv[more verbose output]' \
  '(-v -vv)-vvv[most verbose output]' \
  -w'[Write the raw packets to file]:output file:_files' \
  -W'[Limit the number of created files (-C)]:number of files' \
  -x'[Print each packet (minus its link level header) in hex]' \
  '(-x)-xx[Print each packet, including its link level header, in hex]' \
  -X'[Print each packet (minus its link level header) in hex and ASCII]' \
  '(-X)-XX[Print each packet, including its link level header, in hex and ASCII]' \
  -y'[Set the data link type to use while capturing packets]:data link type:_data_link_types' \
  -Z'[Drops privileges (if root) and changes user ID (along with primary group)]:user:_users' \
  '*:BPF filter:_bpf_filter'

^ permalink raw reply	[flat|nested] 9+ messages in thread

* completion for ipset
  2008-05-29 12:30 new completions for iftop and tcpdump Tomasz Pala
@ 2008-06-23 17:09 ` Tomasz Pala
  2008-06-23 18:52   ` Tomasz Pala
  2009-04-11 18:07   ` completion for ipset Tomasz Pala
  0 siblings, 2 replies; 9+ messages in thread
From: Tomasz Pala @ 2008-06-23 17:09 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 132 bytes --]

Hello,

attached file completes ipset command. I believe it should go into
Completion/Linux.

-- 
Tomasz Pala <gotar@pld-linux.org>

[-- Attachment #2: _ipset --]
[-- Type: text/plain, Size: 6022 bytes --]

#compdef ipset

local offset=0
local -a args from_to hash cmds listopts

_set_types () {
	_values -S \  "Set type" \
		'ipmap[Up to 65536 IP addresses]' \
		'macipmap[Up to 65536 IP addresses with MAC]' \
		'portmap[Up to 65536 ports]' \
		'iphash[Hash of IP addresses]' \
		'nethash[Hash of network addresses]' \
		'ipporthash[Hash of IP address and port pairs]' \
		'iptree[Tree of IP addresses, optionally with timeout]'
}

if [[ $words[2] = (-q|--quiet) ]]; then
	offset=1
fi

_ipsets () {
	local -a vals
	vals=( ${${(M)${(f)"$(_call_program ipsets ipset -nL)"}%Name: *}#Name: } )
	_describe -t ipsets "IP sets" vals
}
_sets () {
	_ipsets
	local -a vals
	case $words[offset+2]; in
	  -X|--destroy)
		vals=('\:all\::remove all not referenced sets')
	  ;;
	  -F|--flush)
		vals=('\:all\::flush all sets')
	  ;;
	  -L|--list|-nL|-sL|-nsL|-snL|-n|-s|-ns|-sn)
		vals=('\:all\::list all sets')
	  ;;
	  -S|--save)
		vals=('\:all\::save all sets')
	esac
	_describe -t special_values "special values" vals
}

from_to=('(--network)--from[from IP or network (with --netmask)]:IP'
	'(--network)--to[to IP or network (with --netmask)]:IP'
	'(--from --to)--network[network]:IP/mask'
)
hash=(	'--hashsize[The initial hash size (default 1024)]:hash size'
	'--probes[Max number of tries to resolve clashing (default 8)]:probes'
	'--resize[Ratio of increasing hash size after unsuccessful <probes> number of double-hashing]:percent'
)

case $words[offset+2]; in
  -N|--create)
	case $words[offset+4]; in
	  ipmap)
		args=(	$from_to
			'--netmask[store network addresses instead of IP addresses]:CIDR'
		)
	  ;;
	  macipmap)
		args=(	$from_to
			'--matchunset[Always match IP addresses which could be stored in the set but are not]'
		)
	  ;;
	  portmap)
		args=(	'--from[from port]:port:_ports'
			'--to[to port]:port:_ports'
		)
	  ;;
	  iphash)
		args=(	$hash
			'--netmask[store network addresses instead of IP addresses]:CIDR'
		)
	  ;;
	  nethash)
		args=(	$hash )
	  ;;
	  ipporthash)
		args=(	$from_to $hash )
	  ;;
	  iptree)
	  	args=(	'--timeout[Timeout value for the entries in seconds (default 0)]:timeout' )
	  ;;
	esac
  ;;
  -T|--test)
	args=(	'(-b --binding)'{-b,--binding}'[Test wether '$words[offset+4]' points to the specified binding]:::_ipsets' )
  ;;
  -B|--bind)
	args=(	'(-b --binding)'{-b,--binding}'[Value of the binding]:::_ipsets' )
  ;;
esac

_ips () {
	if [[ $CURRENT -eq ((offset+4)) ]]; then
		local ips=1 default
		local -a vals vals1 vals2 bindings
		vals=( ${${${(f)"$(_call_program ipsets ipset -nL $words[offset+3])"}[4,-1]}//\:/\\:} )
		for i in $vals; do
			if [[ $i = Default\ binding\\:* ]]; then default=${i#Default binding\\: }; continue; fi
			if [[ $i = (Header\\:*|Members\\:) ]]; then continue; fi
			if [[ $i = 'Bindings\:' ]]; then ips=0; continue; fi
			if (( $ips )); then vals1+=$i; else bindings+=${i/ ->/:}; fi
		done
		case $words[offset+2]; in
		  -T|--test)
			vals2=('\:default\::test default binding of the set for --binding')
		  ;;
		  -B|--binding)
			vals2=('\:default\::set default binding of the set')
		  ;;
		  -U|--unbind)
			vals1=()
			vals2=('\:all\::destroy the bindings of all elements of a set')
			if [[ -n "$default" ]]; then
			vals2+=("\:default\::remove default binding of the set to '$default'")
			fi
			_describe -t ipb "IPs from $words[offset+3] set with bindings" bindings
		  ;;
		esac
		_describe -t ips "IPs from $words[offset+3] set" vals1
		_describe -t special_values "special values" vals2
	fi
}

cmds=(-N -X -F -E -W -S -R -A -D -T -B -U -H --create --destroy --flush --rename --swap --save --restore --add --del --test --bind --unbind --help)
listopts=(-n --numeric -s --sorted -L --list -nL -sL -nsL -snL -ns -sn)

_arguments \
	"($cmds $listopts)"{-N,--create}'[Create a set]:set name::::_set_types' \
	"($cmds $listopts)"{-X,--destroy}'[Destroy specified set (or all if none specified)]:set name:_sets' \
	"($cmds $listopts)"{-F,--flush}'[Flush specified set (or all if none specified)]:set name:_sets' \
	"($cmds $listopts)"{-E,--rename}'[rename set]:current set name:_ipsets:new set name:' \
	"($cmds $listopts)"{-W,--swap}'[swap two sets]:::_ipsets:::_ipsets' \
	"($cmds -L --list -q --quiet -nL -sL -nsL -snL)"{-L,--list}'[List the entries and bindings for the specified set (or all if none specified)]:::_sets' \
	"($cmds -L --list -q --quiet -n --numeric -snL -nsL -sL -ns -sn)"-nL'[List the entries and bindings for the specified set (or all if none specified) \- numeric output]:::_sets' \
	"($cmds -L --list -q --quiet -s --sorted  -snL -nsL -nL -ns -sn)"-sL'[List the entries and bindings for the specified set (or all if none specified) \- sorted output]:::_sets' \
	"($cmds $listopts -q --quiet)"{-nsL,-snL}'[List the entries and bindings for the specified set (or all if none specified) \- sorted numeric output]:::_sets' \
	"($cmds $listopts)"{-S,--save}'[Save the given set (or all if none specified)]:::_sets' \
	"($cmds $listopts)"{-R,--restore}'[Restore a saved session generated by --save from stdin]' \
	"($cmds $listopts)"{-A,--add}'[Add an IP to a set]:::_ipsets:IP' \
	"($cmds $listopts)"{-D,--del}'[Delete an IP from a set]:::_ipsets:::_ips' \
	"($cmds $listopts)"{-T,--test}'[Test wether an IP is in a set or the IP points to the specified binding]:::_ipsets:::_ips' \
	"($cmds $listopts)"{-B,--bind}'[Bind the IP in setname to to-setname]:::_ipsets:::_ips' \
	"($cmds $listopts)"{-U,--unbind}'[Delete the binding belonging to IP in set setname]:::_ipsets:::_ips' \
	"($cmds $listopts)"{-H,--help}'[Print help and settype specific help if settype specified]:::_set_types' \
	"(-q --quiet $listopts)"{-q,--quiet}'[Suppress any output to stdout and stderr]' \
	"($cmds -s --sorted  -q --quiet -sL -nsL -snL -ns -sn)"{-s,--sorted}'[Sorted output]' \
	"($cmds -n --numeric -q --quiet -nL -nsL -snL -ns -sn)"{-n,--numeric}"[Numeric output; don't resolve host names, network names and services]" \
	"($cmds -ns -sn  -q --quiet -nL -sL -nsL -snL -n --numeric -s --sorted)"{-ns,-sn}'[Sorted numeric output]' \
	"$args[@]"

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: completion for ipset
  2008-06-23 17:09 ` completion for ipset Tomasz Pala
@ 2008-06-23 18:52   ` Tomasz Pala
  2008-06-24 12:47     ` Completion for ethtool Tomasz Pala
  2009-04-11 18:07   ` completion for ipset Tomasz Pala
  1 sibling, 1 reply; 9+ messages in thread
From: Tomasz Pala @ 2008-06-23 18:52 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 90 bytes --]

And updated arp completion (handles more options).

-- 
Tomasz Pala <gotar@pld-linux.org>

[-- Attachment #2: _arp --]
[-- Type: text/plain, Size: 1169 bytes --]

#compdef arp

local state line expl curcontext="$curcontext"
local -a cmds

cmds=(-a --display -d --delete -s --set -f --file)

_arguments -C \
  "($cmds 1 -D --use-device)"{-a,--display}'[show entries for all or specified hosts]:host:->hostintable' \
  "($cmds 1 -n --numeric -D --use-device -H --hw-type)"{-d,--delete}'[delete entry from table]:host:->hostintable' \
  "($cmds 1 -n --numeric)"{-s,--set}'[create an ARP entry]:host:_hosts:ethernet address::*:option:(temp trail pub)' \
  "($cmds 1 -n --numeric)"{-f,--file}'[read multiple entries from file]:file:_files' \
  '(-i --device)'{-i,--device}'[Select an interface]:::_net_interfaces:' \
  '(-D --use-device -a --display -d --delete)'{-D,--use-device}"[Use the interface ifa's hardware address]" \
  '(-H --hw-type -d --delete)'{-H,--hw-type}'[class of entries to check for]:class:(ether arcnet pronet ax25 netrom)' \
  '(-n --numeric -d --delete -s --set -f --file)'{-n,--numeric}'[shows numerical addresses]' \
  '(-v --verbose)'{-v,--verbose}'[be verbose]' \
  '(-a)1:host:->hostintable'

[[ "$state" = hostintable ]] &&
  _wanted hosts expl 'host' compadd ${${${(f)"$(${words[1]} -an)"}##[ ?(]#}%%[ )]*}

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Completion for ethtool
  2008-06-23 18:52   ` Tomasz Pala
@ 2008-06-24 12:47     ` Tomasz Pala
  2009-04-11 17:50       ` Tomasz Pala
  0 siblings, 1 reply; 9+ messages in thread
From: Tomasz Pala @ 2008-06-24 12:47 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 476 bytes --]

Note: in _arp completion I've changed:

_wanted hosts expl 'host' compadd ${${${(f)"$(${words[1]} -a)"}##[ ?(]#}%%[ )]*}

to:

_wanted hosts expl 'host' compadd ${${${(f)"$(${words[1]} -an)"}##[ ?(]#}%%[ )]*}

because arp -a without -n for more entries is very slow due to many DNS
lookups. I suppose this change wouldn't be nice for everyone, so how to
make this configurable? Should I introduce some new zstyle?

And ethtool attached.

-- 
Tomasz Pala <gotar@pld-linux.org>

[-- Attachment #2: _ethtool --]
[-- Type: text/plain, Size: 5438 bytes --]

#compdef ethtool

local -a cmds

if [[ $CURRENT -ge 4 ]]; then
	case $words[CURRENT-1]; in
	  rx|tx)
		if [[ $words[2] = '-G' ]] && _message -e n 'number of ring entries' || _wanted -x onoff expl 'enabled' compadd off on
	  ;;
	  autoneg|adaptive-rx|adaptive-tx|raw|sg|tso)
		_wanted -x 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'
	  ;;
	  speed)
		_wanted -x speed expl 'speed' compadd 10 100 1000
	  ;;
	  duplex)
		_wanted -x duplex expl 'duplex mode' compadd half full
	  ;;
	  port)
		_wanted -x port expl 'device port' compadd tp aui bnc mii
	  ;;
	  xcvr)
		_wanted -x xcvr expl 'transceiver type' compadd internal external
	  ;;
	  wol)
		_values -s '' 'Wake-on-LAN options' \
			'(d)p[Wake on phy activity]' \
			'(d)u[Wake on unicast messages]' \
			'(d)m[Wake on multicast messages]' \
			'(d)b[Wake on broadcast messages]' \
			'(d)a[Wake on ARP]' \
			'(d)g[Wake on MagicPacket(tm)]' \
			'(d)s[Enable SecureOn(tm) password for MagicPacket(tm)]' \
			'(p u m b a g s)d[Disable (wake on nothing)]'
	  ;;
	  sopass)
		_message -e secureon 'password - 6 bytes in ethernet MAC hex format (xx:yy:zz:aa:bb:cc)'
	  ;;
	  *)
	case $words[2]; in
	  -A)
		_values -S ' ' -w 'pause options' \
			'autoneg[Specify if pause autonegotiation is enabled]' \
			'rx[Specify if RX pause is enabled]' \
			'tx[Specify if TX pause is enabled]'
	  ;;
	  -C)
		_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'
	  ;;
	  -G)
		_values -S ' ' -w 'ring parameters' \
			'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)
		_values -S ' ' -w 'register dump options' \
			'raw[dump raw register data]'
	  ;;
	  -e)
		_values -S ' ' -w 'EEPROM dump options' \
			'raw[dump raw EEPROM data]' \
			'offset[dump certain portions of the EEPROM]' \
			'length[dump certain portions of the EEPROM]'
	  ;;
	  -E)
		_values -S ' ' -w 'EEPROM values' \
			'magic[device-specific key]' \
			'offset[select byte]' \
			'value[new value]'
	  ;;
	  -K)
		_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]'
	  ;;
	  -p)
		if [[ $CURRENT -eq 4 ]] && _message -e length 'seconds'
	  ;;
	  -t)
		_values -S ' ' -w 'selftest option' \
			'(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]'
	  ;;
	  -s)
		_values -S ' ' -w 'change setting' \
			'speed[Set speed in Mb/s]' \
			'duplex[Set full or half duplex mode]' \
			'port[Select device port]' \
			'autoneg[Specify if autonegotiation is enabled]' \
			'phyad[PHY address]' \
			'xcvr[Select transceiver type]' \
			'wol[Set Wake-on-LAN options]' \
			'sopass[Set the SecureOn(tm) password]' \
			'msglvl[Set the driver message level]'
	  ;;
	esac
	  ;;
	esac
fi

cmds=(-h -a -A -c -C -g -G -i -d -e -E -k -K -p -r -S -t -s)

_arguments \
	"($cmds)1:interface:_net_interfaces" \
	"($cmds 1)-h[shows a short help message]" \
	"($cmds)-a[queries the specified ethernet device for pause parameter information]" \
	"($cmds)-A[change the pause parameters of the specified ethernet device]" \
	"($cmds)-c[queries the specified ethernet device for coalescing information]" \
	"($cmds)-C[change the coalescing settings of the specified ethernet device]" \
	"($cmds)-g[queries the specified ethernet device for RX/TX ring parameter information]" \
	"($cmds)-G[change the RX/TX ring parameters of the specified ethernet device]" \
	"($cmds)-i[queries the specified ethernet device for associated driver information]" \
	"($cmds)-d[retrieves and prints a register dump for the specified ethernet device]" \
	"($cmds)-e[retrieves and prints an EEPROM dump for the specified ethernet device]" \
	"($cmds)-E[Changes EEPROM byte for the specified ethernet device]" \
	"($cmds)-k[queries the specified ethernet device for offload information]" \
	"($cmds)-K[change the offload parameters of the specified ethernet device]" \
	"($cmds)-p[initiates adapter-specific action intended to identify the adapter by sight]" \
	"($cmds)-r[restarts auto-negotiation on the specified ethernet device]" \
	"($cmds)-S[queries the specified ethernet device for NIC- and driver-specific statistics]" \
	"($cmds)-t[executes adapter selftest on the specified ethernet device]" \
	"($cmds)-s[allows changing some or all settings of the specified ethernet device]" \
	'*:' && ret=0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Completion for ethtool
  2008-06-24 12:47     ` Completion for ethtool Tomasz Pala
@ 2009-04-11 17:50       ` Tomasz Pala
  2009-04-11 21:28         ` rpmbuild and mdadm completion Tomasz Pala
  2009-04-16  9:16         ` Completion for ethtool Peter Stephenson
  0 siblings, 2 replies; 9+ messages in thread
From: Tomasz Pala @ 2009-04-11 17:50 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 96 bytes --]

Hello,

update for ethtool completion attached.

regards,
-- 
Tomasz Pala <gotar@pld-linux.org>

[-- Attachment #2: zsh-ethtool.patch --]
[-- Type: text/plain, Size: 7867 bytes --]

--- _ethtool.orig	2008-11-30 15:31:11.000000000 +0100
+++ _ethtool	2009-04-11 19:43:58.000000000 +0200
@@ -7,7 +7,7 @@
 	  rx|tx)
 		if [[ $words[2] = '-G' ]] && _message -e n 'number of ring entries' || _wanted -x onoff expl 'enabled' compadd off on
 	  ;;
-	  autoneg|adaptive-rx|adaptive-tx|raw|sg|tso)
+	  autoneg|adaptive-rx|adaptive-tx|raw|hex|sg|tso|ufo|gso)
 		_wanted -x 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)
@@ -22,6 +22,18 @@
 	  port)
 		_wanted -x port expl 'device port' compadd tp aui bnc mii
 	  ;;
+	  advertise)
+		_values 'hexidecimal value (or a combination of the following)' \
+			'0x001[10 Half]' \
+			'0x002[10 Full]' \
+			'0x004[100 Half]' \
+			'0x008[100 Full]' \
+			'0x010[1000 Half(not supported by IEEE standards)]' \
+			'0x020[1000 Full]' \
+			'0x8000[2500 Full(not supported by IEEE standards)]' \
+			'0x800[10000 Full]' \
+			'0x03F[Auto]'
+	  ;;
 	  xcvr)
 		_wanted -x xcvr expl 'transceiver type' compadd internal external
 	  ;;
@@ -39,15 +51,18 @@
 	  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
+	  ;;
 	  *)
 	case $words[2]; in
-	  -A)
+	  -A|--pause)
 		_values -S ' ' -w 'pause options' \
 			'autoneg[Specify if pause autonegotiation is enabled]' \
 			'rx[Specify if RX pause is enabled]' \
 			'tx[Specify if TX pause is enabled]'
 	  ;;
-	  -C)
+	  -C|--coalesce)
 		_values -S ' ' -w 'coalescing settings' \
 			'adaptive-rx' 'adaptive-tx' \
 			'rx-usecs' 'rx-frames' 'rx-usecs-irq' 'rx-frames-irq' \
@@ -61,50 +76,55 @@
 			'tx-usecs-high' 'tx-frames-high' \
 			'sample-interval'
 	  ;;
-	  -G)
+	  -G|--set-ring)
 		_values -S ' ' -w 'ring parameters' \
 			'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)
+	  -d|--register-dump)
 		_values -S ' ' -w 'register dump options' \
-			'raw[dump raw register data]'
+			'hex[dump hex register data]' \
+			'raw[dump raw register data]' \
+			'file[use contents from file rather than device]'
 	  ;;
-	  -e)
+	  -e|--eeprom-dump)
 		_values -S ' ' -w 'EEPROM dump options' \
 			'raw[dump raw EEPROM data]' \
 			'offset[dump certain portions of the EEPROM]' \
 			'length[dump certain portions of the EEPROM]'
 	  ;;
-	  -E)
+	  -E|--change-eeprom)
 		_values -S ' ' -w 'EEPROM values' \
 			'magic[device-specific key]' \
 			'offset[select byte]' \
 			'value[new value]'
 	  ;;
-	  -K)
+	  -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]'
+			'tso[Specify if TCP segmentation offload is enabled]' \
+			'ufo[Specify if UDP segmentation offload is enabled]' \
+			'gso[Specify if generic segmentation offload is enabled]'
 	  ;;
-	  -p)
+	  -p|--identify)
 		if [[ $CURRENT -eq 4 ]] && _message -e length 'seconds'
 	  ;;
-	  -t)
+	  -t|--test)
 		_values -S ' ' -w 'selftest option' \
 			'(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]'
 	  ;;
-	  -s)
+	  -s|--change)
 		_values -S ' ' -w 'change setting' \
 			'speed[Set speed in Mb/s]' \
 			'duplex[Set full or half duplex mode]' \
 			'port[Select device port]' \
 			'autoneg[Specify if autonegotiation is enabled]' \
+			'advertise[Set the speed and duplex advertised by autonegotiation]' \
 			'phyad[PHY address]' \
 			'xcvr[Select transceiver type]' \
 			'wol[Set Wake-on-LAN options]' \
@@ -116,26 +136,29 @@
 	esac
 fi
 
-cmds=(-h -a -A -c -C -g -G -i -d -e -E -k -K -p -r -S -t -s)
+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[shows a short help message]" \
-	"($cmds)-a[queries the specified ethernet device for pause parameter information]" \
-	"($cmds)-A[change the pause parameters of the specified ethernet device]" \
-	"($cmds)-c[queries the specified ethernet device for coalescing information]" \
-	"($cmds)-C[change the coalescing settings of the specified ethernet device]" \
-	"($cmds)-g[queries the specified ethernet device for RX/TX ring parameter information]" \
-	"($cmds)-G[change the RX/TX ring parameters of the specified ethernet device]" \
-	"($cmds)-i[queries the specified ethernet device for associated driver information]" \
-	"($cmds)-d[retrieves and prints a register dump for the specified ethernet device]" \
-	"($cmds)-e[retrieves and prints an EEPROM dump for the specified ethernet device]" \
-	"($cmds)-E[Changes EEPROM byte for the specified ethernet device]" \
-	"($cmds)-k[queries the specified ethernet device for offload information]" \
-	"($cmds)-K[change the offload parameters of the specified ethernet device]" \
-	"($cmds)-p[initiates adapter-specific action intended to identify the adapter by sight]" \
-	"($cmds)-r[restarts auto-negotiation on the specified ethernet device]" \
-	"($cmds)-S[queries the specified ethernet device for NIC- and driver-specific statistics]" \
-	"($cmds)-t[executes adapter selftest on the specified ethernet device]" \
-	"($cmds)-s[allows changing some or all settings of the specified ethernet device]" \
+	"($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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: completion for ipset
  2008-06-23 17:09 ` completion for ipset Tomasz Pala
  2008-06-23 18:52   ` Tomasz Pala
@ 2009-04-11 18:07   ` Tomasz Pala
  1 sibling, 0 replies; 9+ messages in thread
From: Tomasz Pala @ 2009-04-11 18:07 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 85 bytes --]

Hi,

here goes updated ipset completion code.

-- 
Tomasz Pala <gotar@pld-linux.org>

[-- Attachment #2: zsh-ipset.patch --]
[-- Type: text/plain, Size: 1107 bytes --]

--- _ipset.orig	2008-11-30 15:31:11.000000000 +0100
+++ _ipset	2009-04-11 20:03:40.000000000 +0200
@@ -11,7 +11,11 @@
 		'iphash[Hash of IP addresses]' \
 		'nethash[Hash of network addresses]' \
 		'ipporthash[Hash of IP address and port pairs]' \
-		'iptree[Tree of IP addresses, optionally with timeout]'
+		'ipportiphash[Hash of IP address,port and IP address triples]' \
+		'ipportnethash[Hash of IP address,port and network address triples]' \
+		'iptree[Tree of IP addresses, optionally with timeout]' \
+		'iptreemap[Tree of IP addresses or networks]' \
+		'setlist[List of sets]'
 }
 
 if [[ $words[2] = (-q|--quiet) ]]; then
@@ -77,12 +81,18 @@
 	  nethash)
 		args=(	$hash )
 	  ;;
-	  ipporthash)
+	  ipporthash|ipportiphash|ipportnethash)
 		args=(	$from_to $hash )
 	  ;;
 	  iptree)
 	  	args=(	'--timeout[Timeout value for the entries in seconds (default 0)]:timeout' )
 	  ;;
+	  iptreemap)
+	  	args=(	'--gc[Garbage collection inverval (default 300 seconds)]:timeout' )
+	  ;;
+	  setlist)
+	  	args=(	'--size[Size of the new setlist (default 8)]:size' )
+	  ;;
 	esac
   ;;
   -T|--test)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* rpmbuild and mdadm completion
  2009-04-11 17:50       ` Tomasz Pala
@ 2009-04-11 21:28         ` Tomasz Pala
  2009-04-17 10:52           ` Peter Stephenson
  2009-04-16  9:16         ` Completion for ethtool Peter Stephenson
  1 sibling, 1 reply; 9+ messages in thread
From: Tomasz Pala @ 2009-04-11 21:28 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 932 bytes --]

Hello again,

this time two new completions:

1. rpmbuild has been detached from main rpm binary, according to man:

LEGACY ISSUES
   Executing rpmbuild
       The  build  modes  of  rpm  are  now resident in the /usr/bin/rpmbuild executable.
       Although legacy compatibility provided by the popt aliases  below  has  been  ade-
       quate,  the  compatibility  is not perfect; hence build mode compatibility through
       popt aliases is being removed from rpm.  Install the  rpmbuild  package,  and  see
       rpmbuild(8)  for  documentation  of  all the rpm build modes previously documented
       here in rpm(8).

so the need of separate completion code arises (in fact I missed it for
many years now).


2. mdadm is not complete, but I hasn't developed it further since 1,5 month,
just got no time for this - maybe someone finishes it sometime, for now
it's better than nothing.

-- 
Tomasz Pala <gotar@pld-linux.org>

[-- Attachment #2: _rpmbuild --]
[-- Type: text/plain, Size: 3388 bytes --]

#compdef rpmbuild

local -a cmds b_cmds t_cmds options b_options

cmds=(--rebuild --recompile)
b_cmds=(-ba -bb -bp -bc -bi -bl -bs)
t_cmds=(-ta -tb -tp -tc -ti -tl -ts)
options=(--quiet -v -vv --verbose --rcfile --pipe --dbpath -r --root --buildroot --clean --nobuild --nodeps --nodigest --nosignature --macros
	--rmsource --rmspec --short-circuit --sign --target -D --define -E --eval --with --without --debug --bcond --install-build-tree)
b_options=(--clean --nobuild --nodeps --nodigest --nosignature --rmsource --rmspec --short-circuit --sign --target --debug --with --without)

_arguments \
	"($cmds $b_cmds $t_cmds)"{-ba,-ta}'[Build binary and source packages]' \
	"($cmds $b_cmds $t_cmds)"{-bb,-tb}'[Build a binary package]' \
	"($cmds $b_cmds $t_cmds)"{-bp,-tp}'[Execute the "%prep" stage]' \
	"($cmds $b_cmds $t_cmds)"{-bc,-tc}'[Do the "%build" stage]' \
	"($cmds $b_cmds $t_cmds)"{-bi,-ti}'[Do the "%install" stage]' \
	"($cmds $b_cmds $t_cmds)"{-bl,-tl}'[Do a "list check"]' \
	"($cmds $b_cmds $t_cmds)"{-bs,-ts}'[Build just the source package]' \
	"($cmds $b_cmds $t_cmds * $b_options $options)"{-\?,--help}'[Show help message]' \
	"($cmds $b_cmds $t_cmds * $b_options $options)"--querytags'[Display known query tags]' \
	"($cmds $b_cmds $t_cmds * $b_options)"--showrc'[Display final rpmrc and macro configuration]' \
	"($cmds $b_cmds $t_cmds * $b_options $options)"--usage'[Display brief usage message]' \
	"($cmds $b_cmds $t_cmds * $b_options $options)"--version'[Print the version of rpm being used]' \
	"(-v --verbose -vv)"--quiet'[Print as little as possible]' \
	"(-v --verbose --quiet)"{-v,--verbose}'[Print verbose information]' \
	"(-v --verbose --quiet)"-vv'[Print lots of ugly debugging information]' \
	--rcfile'[RC files]:RC files:_files -S\:' \
	--macros'[Macros files]:Macros files:_files -S\:' \
	--pipe'[Command to pipe the output of rpm to]:command' \
	--dbpath'[Set database directory]:Database directory:_files -/' \
	"(-r --root)"{-r,--root}'[Root file system tree]:Chroot directory:_files -/' \
	--buildroot'[Override the BuildRoot]:BuildRoot directory:_files -/' \
	--clean'[Remove the build tree after the packages are made]' \
	--nobuild'[Do not execute any build stages (for spec testing purposes]' \
	--nodeps'[Do not verify build dependencies]' \
	--nodigest"[Don't verify package digest(s)]" \
	--nosignature"[Don't verify package signature(s)]" \
	--rmsource'[Remove the sources after the build]' \
	--rmspec'[Remove the spec file after the build]' \
	--short-circuit'[Skip straight to specified stage (-bc, -bi or -bb in PLD Linux]' \
	--sign'[Embed a GPG signature]' \
	--target='[Set target platform]:arch-vendor-os:' \
	{'*-D','*--define='}'[Define MACRO with value EXPR]:MACRO EXPR' \
	{'*-E','*--eval='}'[Print macro expansion of EXPR]:EXPR' \
	'*--with[Enable configure option for build]:option' \
	'*--without[Disable configure option for build]:option' \
	"($cmds $b_cmds $t_cmds * $b_options)"--bcond'[Find all --with/--without values]' \
	--debug'[Build packages with debug information]' \
	"($cmds $b_cmds $t_cmds * $b_options)"--install-build-tree'[Make all needed dirs for building binary rpms]' \
	"(--clean $b_cmds $t_cmds --rebuild)"--recompile'[Recompile source package]' \
	"(--clean $b_cmds $t_cmds --recompile)"--rebuild'[Rebuild source package]' \
	"*:file:_files -g '(#i)*.(spec|srpm|tgz|tar|tar.gz|tar.bz2)(-.)'" && ret=0

[-- Attachment #3: _mdadm --]
[-- Type: text/plain, Size: 8004 bytes --]

#compdef mdadm

typeset -A opt_args
local -a args misc modes

_raids_build () {
	_values -S \  "MD device type" \
		'linear[linear]' \
		{0,raid0,stripe}'[striping]' \
		{1,raid1,mirror}'[mirroring]' \
		{multipath,mp}'[multiple paths to one common physical storage device]' \
		'faulty[injects faults]'
}

_raids () {
	_values -S \  "MD device type" \
		'linear[linear]' \
		{0,raid0,stripe}'[striping]' \
		{1,raid1,mirror}'[mirroring]' \
		{4,raid4}'[RAID 4]' \
		{5,raid5}'[RAID 5]' \
		{6,raid6}'[RAID 6]' \
		{10,raid10}'[RAID 1+0]' \
		{multipath,mp}'[multiple paths to one common physical storage device]' \
		'faulty[injects faults]'
}

_layouts () {
	case ${(v)opt_args[(I)-(l|-level)]} in
		5|raid5)
			_values -S \  "RAID5 parity block layout" \
				{left-asymmetric,la}'[left-asymmetric]' \
				{left-symmetric,ls}'[left-symmetric]' \
				{right-asymmetric,ra}'[right-asymmetric]' \
				{right-symmetric,rs}'[right-symmetric]'
			;;
		10|raid10)
	                _values -s ' ' 'RAID10 layout with number of copies of each datablock' \
        	                'n1[Near copies]' \
        	                'n2[Near copies]' \
        	                'n3[Near copies]' \
        	                'n4[Near copies]' \
        	                'n5[Near copies]' \
        	                'n6[Near copies]' \
        	                'n7[Near copies]' \
        	                'n8[Near copies]' \
        	                'n8[Near copies]' \
        	                'f1[Far copies]' \
        	                'f2[Far copies]' \
        	                'f3[Far copies]' \
        	                'f4[Far copies]' \
        	                'f5[Far copies]' \
        	                'f6[Far copies]' \
        	                'f7[Far copies]' \
        	                'f8[Far copies]' \
        	                'f9[Far copies]'
			;;
		faulty)
			_values -S \  "Failure mode" \
				{write-transient,wt}'[write-transient]' \
				{read-transient,rt}'[read-transient]' \
				{write-presistent,wp}'[write-presistent]' \
				{read-presistent,rp}'[read-presistent]' \
				write-all'[write-all]' \
				{read-fixable,rf}'[read-fixable]' \
				{clear,none}'[remove any pending or periodic failure modes]' \
				flush'[clear any persistant faults]'
	esac
}

if (( $+words[(r)-(A|-assemble)] )); then
	args=(
		'(--bitmap)'--bitmap='[bitmap file to use with the array]::Bitmap file:_files'
		'(--uuid -u)'{--uuid=,-u}'[UUID of array to assemble]:UUID'
		'(--super-minor -m)'{--super-minor=,-m}'[minor number to look for in super-block]:Minor number'
		'(--name -N)'{--name=,-N}'[Array name to look for in super-block]:Array name'
		'(--config -c)'{--config=,-c}'[config file]::Config file:_files'
		'(--scan -s)'{--scan,-s}'[scan config file for missing information]'
		'(--run -R)'{--run,-R}'[Try to start the array even if not enough devices for a full array are present]'
		'(--force -f)'{--force,-f}'[Assemble the array even if some superblocks appear out-of-date]'
		'(--update,-U)'{--update=,-U}'[Update superblock]::Update the superblock:(sparc2.2 summaries uuid resync byteorder super-minor)'
	)
fi

if (( $+words[(r)-(B|-build)] )); then
	args=(
		'(--bitmap)'--bitmap='[file to store/find bitmap information in]::Bitmap file:_files'
		'(--chunk -c)'{--chunk=,-c}'[chunk size of kibibytes]:Chunk size'
		'(--rounding)'--rounding='[rounding factor for linear array (==chunk size)]:Rounding factor'
		'(--level -l)'{--level=,-l}'[RAID level]::RAID level:_raids_build'
		'(--raid-devices -n)'{--raid-devices=,-n}'[number of active devices in array]:active devices number'
		'(--bitmap-chunk)'--bitmap-chunk='[bitmap chunksize in Kilobytes]:Bitmap chunk'
		'(--delay -d)'{--delay=,-d}'[bitmap update delay in seconds]:Bitmap update delay'
	)
fi

if (( $+words[(r)-(C|-create)] )); then
	args=(
		'(--bitmap)'--bitmap='[create a bitmap for the array with the given filename]::Bitmap file:_files'
		'(--chunk -c)'{--chunk=,-c}'[chunk size of kibibytes]:Chunk size'
		'(--rounding)'--rounding='[rounding factor for linear array (==chunk size)]:Rounding factor'
		'(--level -l)'{--level=,-l}'[RAID level]::RAID level:_raids'
		'(--parity -p --layout)'{--parity=,-p,--layout=}'[RAID5/6/10 parity algorithm, faulty mode]::Layout:_layouts'
		'(--raid-devices -n)'{--raid-devices=,-n}'[number of active devices in array]:active devices number'
		'(--spare-devices -x)'{--spare-devices=,-x}'[number of spares (eXtras) devices in initial array]:Spare devices number'
		'(--size -z)'{--size=,-z}'[size (in K) of each drive in RAID1/4/5/6/10]:Size of each drive'
		'(--force -f)'{--force,-f}'[honour devices as listed on command line]'
		'(--run -R)'{--run,-R}'[insist of running the array even if not all devices are present or some look odd]'
		'(--readonly -o)'{--readonly,-o}'[start the array readonly]'
		'(--name -N)'{--name=,-N}'[textual name for array - max 32 characters]:Array name'
		'(--bitmap-chunk)'--bitmap-chunk='[bitmap chunksize in Kilobytes]:Bitmap chunk'
		'(--delay -d)'{--delay,-d}'[bitmap update delay in seconds]:Bitmap update delay'
	)
fi

if (( $+words[(r)-([DEXQ]|-(detail|examine(|-bitmap)|query))] )); then
	args=(
		'(--zero-superblock)'--zero-superblock'[erase the MD superblock from a device]'
		'(--run -R)'{--run,-R}'[start a partially built array]'
		'(--stop -S)'{--stop,-S}'[deactivate array, releasing all resources]'
		'(--readonly -o)'{--readonly,-o}'[mark array as readonly]'
		'(--readwrite -w)'{--readwrite,-w}'[mark array as readwrite]'
		'(--test -t)'{--test,-t}'[exit status 0 if ok, 1 if degrade, 2 if dead, 4 if missing]'
	)
fi

if (( $+words[(r)-(F|-follow|-monitor)] )); then
	args=(
		'(--mail -m)'{--mail=,-m}'[Address to mail alerts of failure to]:::_email_addresses'
		'(--program -p --alert)'{--program=,-p,--alert=}'[Program to run when an event is detected]::Program:_files'
		'(--delay -d)'{--delay=,-d}'[seconds of delay between polling state]:seconds'
		'(--config -c)'{--config=,-c}'[specify a different config file]::Config file:_files'
		'(--scan -s)'{--scan,-s}'[find mail-address/program in config file]'
		'(--daemonise -f)'{--daemonise,-f}'[Fork and continue in child, parent exits]'
		'(--pid-file -i)'{--pid-file=,-i}'[In daemon mode write pid to specified file instead of stdout]::PID file:_files'
		'(--oneshot -1)'{--oneshot,-1}'[Check for degraded arrays, then exit]'
		'(--test -t)'{--test,-t}'[Generate a TestMessage event against each array at startup]'
	)
fi

if (( $+words[(r)-(G|-grow)] )); then
	args=(
		'(--size -z)'{--size=,-z}'[Change the active size of devices in an array]:active size'
		'(--raid-disks -n)'{--raid-disks=,-n}'[Change the number of active devices in a RAID1 array]:number of active devices'
	)
fi

_mds () {
	local -a vals
	vals=( ${${${(M)${(f)"$(< /etc/mdadm.conf)"}##ARRAY *}//ARRAY /}%%[[:blank:]]*} )
	_describe -t mds "RAID devices" vals
	_arguments \
		"(-h --help)"{-h,--help}'[Display a mode specific help message]'
}

modes=(-A --assemble -B --build -C --create -F --follow --monitor -G --grow -h --help -V --version)
misc=(-D --detail -E --examine -X --examine-bitmap -Q --query)

_arguments \
	"($misc $modes)"{-A,--assemble}'[Assemble a pre-existing array]:::_mds' \
	"($misc $modes)"{-B,--build}'[Build a legacy array without superblocks]:::_mds' \
	"($misc $modes)"{-C,--create}'[Create a new array]' \
	"($misc $modes)"{-F,--follow,--monitor}'[Select Monitor mode]' \
	"($misc $modes)"{-G,--grow}'[Change the size or shape of an active array]' \
	"($modes -D --detail -E --examine -X --examine-bitmap)"{-D,--detail}'[Print detail of one or more md devices]' \
	"($modes -D --detail -E --examine -X --examine-bitmap -Q --query)"{-E,--examine}'[Print content of md superblock on device(s)]' \
	"($modes -Q --query)"{-Q,--query}'[Examine a device]' \
	"($modes -E --examine -X --examine-bitmap)"{-X,--examine-bitmap}'[Report information about a bitmap file]' \
	"(-)"{-h,--help}'[Display general help message]' \
	"(-)"{-V,--version}'[Print version information for mdadm]' \
	"$args[@]"

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Completion for ethtool
  2009-04-11 17:50       ` Tomasz Pala
  2009-04-11 21:28         ` rpmbuild and mdadm completion Tomasz Pala
@ 2009-04-16  9:16         ` Peter Stephenson
  1 sibling, 0 replies; 9+ messages in thread
From: Peter Stephenson @ 2009-04-16  9:16 UTC (permalink / raw)
  Cc: zsh-users

On Sat, 11 Apr 2009 19:50:18 +0200
Tomasz Pala <gotar@polanet.pl> wrote:
> update for ethtool completion attached.

Please ensure the full path from the top-level directory to the file
appears in patches.  The canonical form is
Completion/Linux/Command/_ethtool, but if there's something in front that
needs stripping off that's not a big deal.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: rpmbuild and mdadm completion
  2009-04-11 21:28         ` rpmbuild and mdadm completion Tomasz Pala
@ 2009-04-17 10:52           ` Peter Stephenson
  0 siblings, 0 replies; 9+ messages in thread
From: Peter Stephenson @ 2009-04-17 10:52 UTC (permalink / raw)
  To: zsh-users

On Sat, 11 Apr 2009 23:28:22 +0200
Tomasz Pala <gotar@polanet.pl> wrote:
> 1. rpmbuild has been detached from main rpm binary, according to man:
> 
> 2. mdadm is not complete, but I hasn't developed it further since 1,5 month,
> just got no time for this - maybe someone finishes it sometime, for now
> it's better than nothing.

[I meant to send this yesterday but it got hidden.  Tomasz already pointed
out I misnamed one file which I've corrected.]

Thanks.

You haven't told me where these go, so I've stuck them in
Completion/Linux/Command.  If someone else with archive access knows they
are more widely used, please move them and update the .distfiles
appropriately.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-04-17 10:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-29 12:30 new completions for iftop and tcpdump Tomasz Pala
2008-06-23 17:09 ` completion for ipset Tomasz Pala
2008-06-23 18:52   ` Tomasz Pala
2008-06-24 12:47     ` Completion for ethtool Tomasz Pala
2009-04-11 17:50       ` Tomasz Pala
2009-04-11 21:28         ` rpmbuild and mdadm completion Tomasz Pala
2009-04-17 10:52           ` Peter Stephenson
2009-04-16  9:16         ` Completion for ethtool Peter Stephenson
2009-04-11 18:07   ` completion for ipset Tomasz Pala

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).