about summary refs log tree commit diff
path: root/Completion/User/_telnet
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-05-05 13:38:45 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-05-05 13:38:45 +0000
commit9f9b6e165516c4ee59b1f5b609a6890ccc3d598f (patch)
tree86460ad1a9886e6030fc1b1d1aee57668f28aa01 /Completion/User/_telnet
parent04118530d4157d3494349e2628246b78465e08f8 (diff)
downloadzsh-9f9b6e165516c4ee59b1f5b609a6890ccc3d598f.tar.gz
zsh-9f9b6e165516c4ee59b1f5b609a6890ccc3d598f.tar.xz
zsh-9f9b6e165516c4ee59b1f5b609a6890ccc3d598f.zip
completion function cleanup for `_arguments' with the `-C' option and using it's return value (11195)
Diffstat (limited to 'Completion/User/_telnet')
-rw-r--r--Completion/User/_telnet85
1 files changed, 67 insertions, 18 deletions
diff --git a/Completion/User/_telnet b/Completion/User/_telnet
index 54d9a0a2d..7b88d016a 100644
--- a/Completion/User/_telnet
+++ b/Completion/User/_telnet
@@ -1,21 +1,70 @@
 #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[@]" }'
+# Parameter used:
+#
+#  telnet_hosts_ports_users
+#    The array that contains 3-tuples `host:port:user'.
 
+local curcontext="$curcontext" state line expl
+typeset -A opt_args
+
+if (( ! $+_telnet_args )); then
+  local help="$(_call options telnet -\? < /dev/null 2>&1)"
+  local -A optionmap
+  optionmap=(
+    '*\[-8\]*' '-8[allow 8-Bit data]'
+    '*\[-E\]*' '-E[disable an escape character]'
+    '*\[-K\]*' '-K[no automatic login]'
+    '*\[-L\]*' '-L[allow 8-Bit data on output]'
+    '*\[-N\]*' '-N[supress reverse lookup]'
+    '*\[-S tos\]*' '-S+:IP type-of-service:'
+    '*\[-X atype\]*' '-X+:authentication type to disable:'
+    '*\[-a\]*' '-a[attempt automatic login]'
+    '*\[-c\]*' '-c[disable .telnetrc]'
+    '*\[-d\]*' '-d[debug mode]'
+    '*\[-e char\]*' '-e+[specify escape character]:escape character:'
+    '*\[-f/*' '-f'
+    '*/-F\]*' '-F'
+    '*\[-k realm\]*' '-k+:realm:'
+    '*\[-l user\]*' '-l+[specify user]:user:->users'
+    '*\[-n tracefile\]*' '-n+[specify tracefile]:tracefile:_files'
+    '*\[-r\]*' '-r[rlogin like user interface]'
+    '*\[-s src_addr\]*' '-s+[set source IP address]:src_addr:'
+    '*\[-x\]*' '-x'
+    '*\[-t transcom\]*' '-t+:transcom:'
+    '*\[-noasynch\]*' '-noasynch'
+    '*\[-noasyncnet\]*' '-noasyncnet'
+    '*\[-noasynctty\]*' '-noasynctty'
+  )
+  _telnet_args=($optionmap[(K)"$help"])
+fi
+
+_arguments -C -s \
+  "$_telnet_args[@]" \
+  ':host:->hosts' \
+  ':port:->ports' && return 0
+
+case "$state" in
+hosts)
+  _wanted hosts expl host \
+      _combination -s '[@:]' '' users-hosts-ports \
+          ${opt_args[-l]:+users=${opt_args[-l]:q}} \
+          hosts -
+  ;;
+
+ports)
+  _wanted ports expl port \
+      _combination -s '[@:]' '' users-hosts-ports \
+          ${opt_args[-l]:+users=${opt_args[-l]:q}} \
+          hosts="${line[1]:q}" \
+          ports -
+  ;;
+
+users)
+  _wanted users expl user \
+      _combination -s '[@:]' '' users-hosts-ports \
+      ${line[2]:+hosts="${line[2]:q}"} \
+      ${line[3]:+ports="${line[3]:q}"} \
+      users -
+  ;;
+esac