Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
_values again and new _ifconfig
- X-seq: zsh-workers 16366
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: _values again and new _ifconfig
- Date: Wed, 19 Dec 2001 15:00:58 +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Sender: kiddleo@xxxxxxxxxxxxxxxxx
The patch adds completion for ifconfig. ifconfig varies across systems
so there is plenty of scope for updates to it to handle more systems.
I've put completion for network interfaces in a separate function.
_ifconfig shows up another limitation of _values. If values are
separated from their arguments by a space (unquoted), it'll go on
completing more values instead of the previous value's arguments.
What I think is that -S ' ', should mean that the separator is a quoted
space and that with -w, the default for -S should not be '=' but also
separate words. And, -S should be another letter but I'll leave that
argument for when the suffix handling discussion comes up.
I also noticed a few cases where the description had been forgotten
from an _values call. I also think it might be better to ditch that
argument to _values and require _description to be used.
Oliver
Index: Completion/Unix/Command/_ifconfig
===================================================================
RCS file: _ifconfig
diff -N _ifconfig
--- /dev/null Thu May 24 22:33:05 2001
+++ _ifconfig Wed Dec 19 06:55:04 2001
@@ -0,0 +1,82 @@
+#compdef ifconfig
+
+local context state line ret=1
+local -a opts args alias debug updownlist
+
+alias=( '(-alias alias)'{,-}'alias[remove or establish alternate address for if]' )
+debug=( '(-debug debug)'{,-}'debug[disable or enable debugging code]' )
+updownlist=(
+ '(-a -d -C)-u[restrict to interfaces which are up]'
+ '(-a -u -C)-d[restrict to interfaces which are down]'
+ '(-a -C -m -L 1 *)-l[list interfaces]'
+)
+
+case $OSTYPE in
+ darwin*)
+ args=( -s $updownlist )
+ opts=(
+ $alias $debug delete dest_address ipdst nsellength
+ {,-}trailers {,-}link{0,1,2}
+ )
+ ;;
+ freebsd*)
+ args=( -s $updown
+ '(-a -l -u -d -m -L 1 *)-C[list interface cloners]'
+ '(-l -C)-m[list supported media]'
+ '(-l -C)-L[show address lifetime as time offset]'
+ )
+ opts=( $alias $debug
+ anycast lladdr media {,-}mediaopt {,delete}tunnel create destroy
+ {,un}plumb vlan {,-}vlandev metric prefixlen range phase ssid muid
+ stationname channel authmode {,-}powersave powersavesleep wepmode
+ {,-}wep {,-}nwkey add delete ether {,-}link{0,1,2}
+ )
+ ;;
+ irix5*) opts=( $debug ) ;;
+ irix6*)
+ opts=( $debug {-,}highbw {,-}link{0,1,2} primary rspace sspace )
+ args=( '-w[display additional information]' )
+ ;;
+ linux*)
+ opts=(
+ '(-promisc promisc)'{,-}'promisc[disable or enable promiscuous mode]'
+ '(-allmulti allmulti)'{,-}'allmulti[disable or enable all-multicast]'
+ 'media[set physical port type]:medium type:(auto 10base2 10baseT AUI)'
+ 'hw[set hardware class]:hardware class:(ether ax25 ARCnet netrom)'
+ add del dstaddr io_addr irq mem_start multicast pointopoint
+ tunnel txqueuelen
+ )
+ ;;
+ solaris*)
+ args=(
+ '-ad[apply to all down interfaces]'
+ '-adD[apply to all down interfaces not controlled by DHCP]'
+ '-au[apply to all up interfaces]'
+ '-auD[apply to all up interfaces not controlled by DHCP]'
+ )
+ opts=(
+ 'auto-revarp[use RARP to acquire address]'
+ {,-}trailers {,-}private {,un}plumb
+ '(dhcp auto-dhcp)'{,auto-}'dhcp[use dhcp]'
+ primary wait drop extend ping release start status
+ )
+ ;;
+esac
+
+_arguments "$args[@]" \
+ '-a[apply to all interfaces]' \
+ '1:network interface:_net_interfaces' \
+ '::address family:(atalk ether inet inet6 ax25 ddp ipx netrom)' \
+ '*:option:->options' && ret=0
+
+[[ -n "$state" ]] && _values -S ' ' -w 'option' "$opts[@]" \
+ '(down)up[activate interface]' \
+ '(up)down[shut down interface]' \
+ '(-arp arp)'{,-}'arp[disable or enable address resolution protocol]' \
+ 'metric[set routing metric for interface]:routing metric' \
+ 'mtu[set maximum transfer unit]:mtu' \
+ 'netmask[specify network mask]:netmask' \
+ 'broadcast[specify broadcast address]:broadcast address' \
+ 'address[specify IP address of interface]:IP address' && ret=0
+
+return ret
Index: Completion/Unix/Command/_java
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_java,v
retrieving revision 1.3
diff -u -r1.3 _java
--- Completion/Unix/Command/_java 2001/05/29 17:54:37 1.3
+++ Completion/Unix/Command/_java 2001/12/19 14:55:04
@@ -360,10 +360,11 @@
debug)
if [[ -prefix :*, ]]; then
compset -P :
- _values -s , lines vars source
+ _values -s , "debug info" lines vars source
else
- compadd -P: none
- compadd -P: -qS, lines vars source
+ _description debuginfo expl "debug info"
+ compadd -P: "$expl[@]" none
+ compadd -P: -qS, "$expl[@]" lines vars source
fi
;;
Index: Completion/Unix/Command/_samba
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_samba,v
retrieving revision 1.1
diff -u -r1.1 _samba
--- Completion/Unix/Command/_samba 2001/09/11 09:42:56 1.1
+++ Completion/Unix/Command/_samba 2001/12/19 14:55:04
@@ -35,7 +35,7 @@
'(-N -A)2:password'
'(2)-s+[specify location of smb.conf]:smb.conf location:_files'
'(2)-O+[specify socket options]:socket options'
- '(2)-R+[specify name resolution order]:name resolution order:_values -s " " lmhosts host wins bcast'
+ '(2)-R+[specify name resolution order]:name resolution order:_values -s " " "name resolution order" lmhosts host wins bcast'
'(2 -L -D -T)-M+[send message]:host:_hosts'
'(2)-i+[specify NetBIOS scope]:scope'
'(2)-N[suppress password prompt]'
Index: Completion/Unix/Type/_net_interfaces
===================================================================
RCS file: _net_interfaces
diff -N _net_interfaces
--- /dev/null Thu May 24 22:33:05 2001
+++ _net_interfaces Wed Dec 19 06:55:04 2001
@@ -0,0 +1,22 @@
+#autoload
+
+local expl list intf sep
+local -a disp
+
+case $OSTYPE in
+ aix*)
+ intf=( ${(f)"$(lsdev -C -c if -F 'name:description')"} )
+ if zstyle -T ":completion:${curcontext}" verbose; then
+ zstyle -s ":completion:${curcontext}:" list-separator sep || sep=--
+ zformat -a list " $sep " "$intf[@]"
+ disp=(-ld list)
+ fi
+ ;;
+ darwin*|freebsd*) intf=( $(ifconfig -l) ) ;;
+ irix*) intf=( ${${${(f)"$(/usr/etc/netstat -i)"}%% *}[2,-1]} ) ;;
+ linux*) intf=( /proc/sys/net/ipv4/conf/*~*(all|default)(N:t) ) ;;
+ *) intf=( $(ifconfig -a|sed -n 's/^\([^ :]*\).*/\1/p') ) ;;
+esac
+
+_wanted interfaces expl 'network interface' \
+ compadd "$@" "$disp[@]" - "${(@)intf%%:*}"
Index: Completion/X/Command/_vnc
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/X/Command/_vnc,v
retrieving revision 1.3
diff -u -r1.3 _vnc
--- Completion/X/Command/_vnc 2001/06/28 11:22:55 1.3
+++ Completion/X/Command/_vnc 2001/12/19 14:55:04
@@ -21,7 +21,7 @@
;;
*vncviewer)
_xt_arguments -shared -viewonly -fullscreen -bgr233 -owncmap -truecolour \
- '-encodings:encodings:_values -s " " copyrect hextile corre rre raw' \
+ '-encodings:encodings:_values -s " " encoding copyrect hextile corre rre raw' \
'-depth:depth' \
'-passwd:file:_files' \
'(1)-listen:display number' \
_____________________________________________________________________
This message has been checked for all known viruses by the
MessageLabs Virus Scanning Service. For further information visit
http://www.messagelabs.com/stats.asp
Messages sorted by:
Reverse Date,
Date,
Thread,
Author