about summary refs log tree commit diff
path: root/Completion/User/_socket
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/User/_socket')
-rw-r--r--Completion/User/_socket49
1 files changed, 35 insertions, 14 deletions
diff --git a/Completion/User/_socket b/Completion/User/_socket
index 353a66fd5..af9c8ab0a 100644
--- a/Completion/User/_socket
+++ b/Completion/User/_socket
@@ -1,34 +1,55 @@
 #compdef socket
 
-local state line expl
-typeset -A options
+# Style used:
+#
+#  hosts-ports
+#    The style that contains pairs `host:port'.
 
-_arguments -s \
-  -{b,c,f,q,r,v,w} \
-  -{s,l} \
-  '-p:command:->command' \
+local curcontext="$curcontext" state line expl
+typeset -A opt_args
+
+[[ $CURRENT -eq 2 ]] &&
+    { ! zstyle -T ":completion:${curcontext}:options" prefix-needed ||
+      [[ "$PREFIX" = -* ]] } &&
+    _wanted options expl option \
+        compadd -M 'r:|[_-]=* r:|=*' "$expl[@]" - -version
+
+_arguments -C -s \
+  '-b[background]' \
+  '-c[crlf]' \
+  '-f[fork]' \
+  '-q[quit]' \
+  '-r[read only]' \
+  '-v[verbose]' \
+  '-w[write only]' \
+  '-s[server]' \
+  '-l[loop]' \
+  '-p[program]:command:->command' \
   ':arg1:->arg1' \
   ':arg2:->arg2'
 
 case "$state" in
 command)
   compset -q
-  _normal
+  if [[ $CURRENT -eq 1 ]]; then
+    _command_names -e "$@"
+  else
+    _normal
+  fi
   ;;
 
 arg1)
-  if (( $+options[-s] )); then
-    _message 'port'
+  if (( $+opt_args[-s] )); then
+    _ports
   else
-    _description expl 'host'
-    _hosts "$expl[@]"
+    _wanted hosts expl 'host' _combination '' hosts-ports hosts -
   fi
   ;;
 
 arg2)
-  if (( ! $+options[-s] )); then
-    _description expl 'port'
-    _hostports $line[2] "$expl[@]"
+  if (( ! $+opt_args[-s] )); then
+    _wanted ports expl 'port to connect' \
+        _combination '' hosts-ports hosts="${line[1]:q}" ports -
   fi
   ;;
 esac