1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-21 00:01:26 +01:00

Tomasz Pala: users/14030,14031,14032: Linux completion updates

This commit is contained in:
Peter Stephenson 2009-04-16 09:25:34 +00:00
parent 87a727ca39
commit 4fdb6c2352
6 changed files with 331 additions and 41 deletions

View file

@ -1,3 +1,14 @@
2009-04-16 Peter Stephenson <pws@csr.com>
* Tomasz Pala: users/14031: Completion/Linux/Command/_ipset:
updates.
* Tomasz Pala: users/14032: Completion/Linux/Command/_mdmadm,
Completion/Linux/Command/_rpmbuild: new completions.
* Tomasz Pala: users/14030: Completion/Linux/Command/_ethtool:
update.
2009-04-07 Peter Stephenson <pws@csr.com>
* Bart: 26822: Completion/Zsh/Context/_subscript: ">" should
@ -11533,5 +11544,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
* $Revision: 1.4646 $
* $Revision: 1.4647 $
*****************************************************

View file

@ -1,9 +1,31 @@
DISTFILES_SRC='
.distfiles
_acpi _acpitool _analyseplugin _brctl _chrt
_ethtool _fusermount _ionice _ipset _iptables
_iwconfig _losetup _lsusb _mii-tool _modutils
_mondo _pkgtool _sshfs _strace _tpb
_tpconfig _tune2fs _uml _valgrind _vserver
_yast
_acpi
_acpitool
_analyseplugin
_brctl
_chrt
_ethtool
_fusermount
_ionice
_ipset
_iptables
_iwconfig
_losetup
_lsusb
_mdmadm
_mii-tool
_modutils
_mondo
_pkgtool
_rpmbuild
_sshfs
_strace
_tpb
_tpconfig
_tune2fs
_uml
_valgrind
_vserver
_yast
'

View file

@ -7,7 +7,7 @@ if [[ $CURRENT -ge 4 ]]; then
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 @@ if [[ $CURRENT -ge 4 ]]; then
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 @@ 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
;;
*)
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 @@ if [[ $CURRENT -ge 4 ]]; then
'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 @@ if [[ $CURRENT -ge 4 ]]; then
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

View file

@ -11,7 +11,11 @@ _set_types () {
'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 @@ case $words[offset+2]; in
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)

View file

@ -0,0 +1,171 @@
#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[@]"

View file

@ -0,0 +1,53 @@
#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