blob: b1c628d1132aa35903179ce98a47de5b1ec01e16 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#compdef telnet
# Parameter used:
#
# telnet_hosts_ports_users
# The array that contains 3-tuples `host:port:user'.
local state line expl
typeset -A opt_args
if (( ! $+_telnet_short )); then
local k help="$(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:' )
_telnet_short=()
for k in ${(k)optionmap}
do
[[ "$help" = *"$k"* ]] &&
_telnet_short=( "$_telnet_short[@]" "$optionmap[$k]" )
done
# _arguments cannot handle following three options.
optionmap=( "[-noasynch]" '-noasynch' \
"[-noasyncnet]" '-noasyncnet' \
"[-noasynctty]" '-noasynctty' )
_telnet_long=()
for k in ${(k)optionmap}
do
[[ "$help" = *"$k"* ]] &&
_telnet_long=( "$_telnet_long[@]" "$optionmap[$k]" )
done
fi
[[ $#_telnet_long != 0 && (
-z "$compconfig[option_prefix]" ||
"$compconfig[option_prefix]" = *\!${words[1]}* ||
"$PREFIX" = [-+]* ) ]] && {
_description expl 'option'
_describe -o option _telnet_long "$expl[@]"
}
_arguments -s \
"$_telnet_short[@]" \
':host:->hosts' \
':port:->ports'
case "$state" in
hosts)
_description expl 'host'
_combination telnet_hosts_ports_users \
${opt_args[-l]:+users=${opt_args[-l]:q}} \
hosts "$expl[@]"
;;
ports)
_description expl 'port'
_combination telnet_hosts_ports_users \
${opt_args[-l]:+users=${opt_args[-l]:q}} \
hosts="${line[2]:q}" \
ports "$expl[@]"
;;
users)
_description expl 'user'
_combination telnet_hosts_ports_users \
${line[2]:+hosts="${line[2]:q}"} \
${line[3]:+ports="${line[3]:q}"} \
users "$expl[@]"
;;
esac
|