zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: _hosts, _hostports, _telnet and _socket
@ 1999-09-12  0:00 Tanaka Akira
  1999-09-12  2:20 ` Bart Schaefer
  1999-09-12 11:26 ` Andrej Borsenkow
  0 siblings, 2 replies; 14+ messages in thread
From: Tanaka Akira @ 1999-09-12  0:00 UTC (permalink / raw)
  To: zsh-workers

I made `_telnet' and `_socket'. They may complete port number and
names depend on a host argument.

So I extended the format of the variable `hosts' to be able to contain
port numbers and names as:

hosts=(... host:port ...)

For that purpose, I modified `_hosts' to handle this format and made
`_hostports' to complete port numbers and names depend on a host.

Index: Completion/User/_hosts
===================================================================
RCS file: /projects/zsh/zsh/Completion/User/_hosts,v
retrieving revision 1.1.1.11
diff -u -F^( -r1.1.1.11 _hosts
--- _hosts	1999/09/06 18:36:15	1.1.1.11
+++ _hosts	1999/09/11 23:42:55
@@ -1,8 +1,8 @@
-#compdef ftp ncftp ping rwho rup xping traceroute telnet
+#compdef ftp ncftp ping rwho rup xping traceroute
 
 local expl
 
 : ${(A)hosts:=${(s: :)${(ps:\t:)${${(f)"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
 
 _description expl host
-compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" "$expl[@]" - "$hosts[@]"
+compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" "$expl[@]" - "${hosts[@]%:*}"
--- /dev/null	Sun Sep 12 07:58:58 1999
+++ Completion/User/_hostports	Sun Sep 12 08:36:42 1999
@@ -0,0 +1,9 @@
+#autoload
+
+# Usage: _hostport host
+
+local host="$1"
+shift
+
+compadd "$@" - ${${(M)hosts\:#$host\:*}#*\:}
+
--- /dev/null	Sun Sep 12 07:58:58 1999
+++ Completion/User/_telnet	Sun Sep 12 08:40:05 1999
@@ -0,0 +1,21 @@
+#compdef telnet
+
+_arguments -s \
+  -{F,f,x} \
+  '-8[allow 8-Bit data]' \
+  '-E[disable an escape character]' \
+  '-K[no automatic login]' \
+  '-L[allow 8-Bit data on output]' \
+  '-S+:IP type-of-service:' \
+  '-X+:authentication type to disable:' \
+  '-a[attempt automatic login]' \
+  '-c[disable .telnetrc]' \
+  '-d[debug mode]' \
+  '-e+[specify escape character]:escape character:' \
+  '-k+:realm:' \
+  '-l+[specify user]:user:' \
+  '-n+[specify tracefile]:tracefile:_files' \
+  '-r[rlogin like user interface]' \
+  ':host:_hosts' \
+  ':port:{ _hostports $line[2] "$expl[@]" }'
+
--- /dev/null	Sun Sep 12 07:58:58 1999
+++ Completion/User/_socket	Sun Sep 12 08:40:14 1999
@@ -0,0 +1,34 @@
+#compdef socket
+
+local state line expl
+typeset -A options
+
+_arguments -s \
+  -{b,c,f,q,r,v,w} \
+  -{s,l} \
+  '-p:command:->command' \
+  ':arg1:->arg1' \
+  ':arg2:->arg2'
+
+case "$state" in
+command)
+  compset -q
+  _normal
+  ;;
+
+arg1)
+  if (( $+options[-s] )); then
+    _message 'port'
+  else
+    _description expl 'host'
+    _hosts "$expl[@]"
+  fi
+  ;;
+
+arg2)
+  if (( ! $+options[-s] )); then
+    _description expl 'port'
+    _hostports $line[2] "$expl[@]"
+  fi
+  ;;
+esac
-- 
Tanaka Akira


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: PATCH: _hosts, _hostports, _telnet and _socket
@ 1999-09-14  8:34 Sven Wischnowsky
  1999-09-15 12:56 ` Tanaka Akira
  0 siblings, 1 reply; 14+ messages in thread
From: Sven Wischnowsky @ 1999-09-14  8:34 UTC (permalink / raw)
  To: zsh-workers


Tanaka Akira wrote:

> Hm. As Adam Spiers mentioned, relations between host-port aren't
> special. And I found that `telnet' has `-l' option that specifies
> `user'.  I think the argument of `-l' should be considered when
> completion. So, I prefer more general way to specify such relations.
> 
> I made `_combination' and `_ports' and modified `_socket' and
> `_telnet' to use them.
> 
> # Is there a better name for `_combination'?

At least it is generic enough to go into Base, I think.

> Now `_telnet' can handle following 7 situations.
> 
> ...

This is nice, but a more powerful `_ports' would still be useful for
all the other commands that use port numbers (_rpm, _mount, _nslookup, 
_ssh, _yp). Sometimes looking at the command name to decide which
ports to suggest is enough, but sometimes we might want to look at
other context information (this port forwarding thing in _ssh, for
example). I don't have any ideas about all this, yet, I just thought I 
should mention it.

And while I'm at it: we still need descriptions for the new parameters 
used and the `_combination' and `_regex_arguments' functions in the
docs.

(Btw, did I already ask if someone knows of other parameters used by
the completion system that aren't documented in the config section of
compsys.yo, yet?)

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

end of thread, other threads:[~1999-09-19  0:49 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-12  0:00 PATCH: _hosts, _hostports, _telnet and _socket Tanaka Akira
1999-09-12  2:20 ` Bart Schaefer
1999-09-12  3:36   ` Tanaka Akira
1999-09-12 21:25     ` Adam Spiers
1999-09-13 14:06       ` Clint Adams
1999-09-13  9:09     ` Peter Stephenson
1999-09-13 18:20       ` Tanaka Akira
1999-09-14 14:25       ` Clint Adams
1999-09-12 11:26 ` Andrej Borsenkow
1999-09-12 12:26   ` Tanaka Akira
1999-09-17  0:57     ` Tanaka Akira
1999-09-19  0:49       ` Bart Schaefer
1999-09-14  8:34 Sven Wischnowsky
1999-09-15 12:56 ` Tanaka Akira

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).