zsh-workers
 help / color / mirror / code / Atom feed
From: Tanaka Akira <akr@jaist.ac.jp>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: _hosts, _hostports, _telnet and _socket
Date: 12 Sep 1999 09:00:59 +0900	[thread overview]
Message-ID: <rsq671hathg.fsf@crane.jaist.ac.jp> (raw)

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


             reply	other threads:[~1999-09-12  0:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-12  0:00 Tanaka Akira [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=rsq671hathg.fsf@crane.jaist.ac.jp \
    --to=akr@jaist.ac.jp \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).