summary refs log tree commit diff
path: root/Completion/User
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-10-16 05:13:05 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-10-16 05:13:05 +0000
commit9a247092cbc80052c04048c926708aad7c289a1e (patch)
treee9f2c5f93f6c01afc0ca31d8acede5128b18544f /Completion/User
parent10c661c3e8dece31254d04857d562647901f31a3 (diff)
downloadzsh-9a247092cbc80052c04048c926708aad7c289a1e.tar.gz
zsh-9a247092cbc80052c04048c926708aad7c289a1e.tar.xz
zsh-9a247092cbc80052c04048c926708aad7c289a1e.zip
Initial revision
Diffstat (limited to 'Completion/User')
-rw-r--r--Completion/User/_archie30
-rw-r--r--Completion/User/_whois211
2 files changed, 241 insertions, 0 deletions
diff --git a/Completion/User/_archie b/Completion/User/_archie
new file mode 100644
index 000000000..92551156e
--- /dev/null
+++ b/Completion/User/_archie
@@ -0,0 +1,30 @@
+#compdef archie
+
+local state line
+typeset -A opt_args
+
+_arguments -s \
+  '-D[debug level]' \
+  '-v[print version]' \
+  '-V[verbose mode]' \
+  '-O[specifies offset]:offset:' \
+  '-a[list matches as Alex filenames]' \
+  '-c[case sensitive substring search]' \
+  '-e[exact string match (default)]' \
+  '-r[regular expression search]' \
+  '-s[case insensitive substring search]' \
+  '-l[list one match per line]' \
+  '-t[sort inverted by date]' \
+  '-m[specifies maximum number of hits to return (default 95)]:hits to return:' \
+  '-o[specifies file to store results in]:file to store:' \
+  '-h[specifies server host]:server host:->serverhost' \
+  '-L[list known servers and current default]' \
+  '-N-[specifies query niceness level (0-35765)]:niceness level:' \
+  ':string:'
+
+case "$state" in
+serverhost)
+  : ${(A)archie_servers:=${(M)$(archie -L):#archie.*}}
+  compadd $archie_servers
+  ;;
+esac
diff --git a/Completion/User/_whois b/Completion/User/_whois
new file mode 100644
index 000000000..827ebe627
--- /dev/null
+++ b/Completion/User/_whois
@@ -0,0 +1,211 @@
+#compdef whois
+
+_whois () {
+  setopt localoptions extendedglob
+  _whois_setup
+  $_whois_comp
+}
+
+builtin functions _whois_setup >&- ||
+_whois_setup () {
+  (( $+_whois_defaultserver )) ||
+    _whois_defaultserver='whois.internic.net'
+
+  (( $+_whois_servers )) || {
+    typeset -gUa _whois_servers
+    _whois_servers=(
+      $_whois_defaultserver
+      domain-registry.nl
+      is.nic.pw
+      whois.apnic.net:p
+      whois.arin.net:a
+      whois.aunic.net
+      whois.berkeley.edu
+      whois.cdnnet.ca
+      whois.dns.pt
+      whois.funet.fi
+      whois.gb.com
+      whois.gb.net
+      whois.internic.net
+      whois.jpl.nasa.gov
+      whois.nic-se.se
+      whois.nic.ad.jp
+      whois.nic.af
+      whois.nic.as
+      whois.nic.br
+      whois.nic.bt
+      whois.nic.ch
+      whois.nic.cx
+      whois.nic.fr
+      whois.nic.gov:g
+      whois.nic.hm
+      whois.nic.it
+      whois.nic.li
+      whois.nic.lk
+      whois.nic.mil:d
+      whois.nic.mx
+      whois.nic.nu
+      whois.nic.or.kr
+      whois.nic.sh
+      whois.nic.tj
+      whois.nic.tm
+      whois.nic.uk
+      whois.ripe.net:r
+      whois.ripn.net:R
+      whois.sics.se
+      whois.stanford.edu
+      whois.uk.com
+      www.nic.at
+      $(functions -m '_whois:*' |
+	awk '/^undefined _whois:/ {print substr($2,8,length($2)-7)}
+	     /^_whois:/ {print substr($1,8,length($1)-7)}')
+    )
+  }
+
+  (( $+_whois_arguments )) || {
+    local help="$(whois </dev/null 2>&1)"
+    local tmp opt opts
+
+    if [[ $help = *"user[@<whois.server>]"* ]]; then
+      _whois_comp=_whois_fwhois
+    elif [[ $help = *(name\ ...|OBJECT...)* ]]; then
+      _whois_comp=_whois_multi
+    else
+      _whois_comp=_whois_single
+    fi
+
+    _whois_arguments=()
+
+    if [[ $help = *"-p PORT"* ]]; then
+      _whois_arguments=("$_whois_arguments[@]"
+        '-p[port]:port:_whois_ports'
+      )
+    fi
+
+    tmp="${(j::)${(@)${(@M)_whois_servers:#*:?}##*:}}" 
+    if [[ $help = (#b)*\[-([$tmp]##)\]* ]]; then
+      tmp=(${(s::)match[1]})
+    else
+      tmp=()
+    fi
+
+    if [[ $help = *"-h host"* ]]; then
+      tmp=($tmp h)
+    fi
+
+    for opt in $tmp; do
+      opts=(-${^tmp:#$opt})
+      if (( $#opts )); then opts="($opts)"; else opts=; fi
+      _whois_arguments=("$_whois_arguments[@]"
+	"${opts}-${opt}[${${${(@M)_whois_servers:#*:$opt}%:?}:-specify host}]${(M)${(M)opt:#h}/h/:host:_whois_hosts}"
+      )
+    done
+  }
+}
+
+_whois_single () {
+  local state line expl
+  typeset -A opt_args
+  local tmp host
+
+  _arguments \
+    "$_whois_arguments[@]" \
+    ':identifier:->identifier'
+
+  case "$state" in
+  identifier)
+    if [[ -z "$QIPREFIX" ]]; then
+      compadd -QS '' \'
+      return
+    fi
+    compset -q
+    host="${opt_args[-h]:-$_whois_defaultserver}"
+    for tmp in $_whois_servers; do
+      if [[ $tmp = *:? && $+opt_args[-${tmp##*:}] -ne 0 ]]; then
+	host="${tmp%:?}"
+        break
+      fi
+    done
+    if builtin functions "_whois:$host" >&-; then
+      "_whois:$host" "$expl[@]"
+    else
+      _message "identifier"
+    fi
+    ;;
+  esac
+}
+
+_whois_multi () {
+  local state line expl
+  typeset -A opt_args
+  local tmp host
+
+  _arguments \
+    "$_whois_arguments[@]" \
+    '*::identifier:->identifier'
+
+  case "$state" in
+  identifier)
+    host="${opt_args[-h]:-$_whois_defaultserver}"
+    for tmp in $_whois_servers; do
+      if [[ $tmp = *:? && $+opt_args[-${tmp##*:}] -ne 0 ]]; then
+	host="${tmp%:?}"
+        break
+      fi
+    done
+    if builtin functions "_whois:$host" >&-; then
+      "_whois:$host" "$expl[@]"
+    else
+      _message "identifier"
+    fi
+    ;;
+  esac
+}
+
+_whois_fwhois () {
+  if compset -P '*@'; then
+    _whois_hosts "$@"
+  else
+    if [[ -z "$QIPREFIX" ]]; then
+      compadd -QS '' \'
+      return
+    fi
+    compset -q
+    host="$_whois_defaultserver"
+    if builtin functions "_whois:$host" >&-; then
+      "_whois:$host" "$@"
+    else
+      _message "identifier"
+    fi
+  fi
+}
+
+_whois_hosts () {
+  compadd "$@" \
+    -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' \
+    - ${_whois_servers%:?} || _hosts "$@"
+}
+
+_whois_ports () {
+  compadd "$@" - whois || _ports "$@"
+}
+
+builtin functions _whois:whois.internic.net >&- ||
+_whois:whois.internic.net () {
+  if (( CURRENT == 1 )); then
+    compadd HELP DOMAIN HOST
+  else
+    _message 'string'
+  fi
+}
+
+builtin functions _whois:whois.nic.ad.jp >&- ||
+_whois:whois.nic.ad.jp () {
+  if (( CURRENT == 1 )); then
+    compadd HELP DOM NET HOST PERSON CONN COM
+  else
+    _message 'string'
+  fi
+}
+
+_whois "$@"