1#compdef links
2
3local curcontext="$curcontext" state line ret=1
4typeset -A opt_args
5
6_arguments -C \
7  '(-help)-anonymous[restrict links so that it can run on an anonymous account]' \
8  '(-help)-assume-codepage[specify default codepage to use]:codepage' \
9  '(-help)-async-dns[asynchronous DNS resolver]:bool:((0\:on 1\:off))' \
10  '(-help)-download-dir[default download directory]:_files -/' \
11  '(-help)-driver[graphics driver to use]:graphics driver:->graphics_drivers' \
12  '(-help)-dump[dump the page as pure text]' \
13  '(-help)-format-cache-size[number of formatted document pages cached]:pages' \
14  '(-help)-ftp-proxy[specify ftp proxy server]:proxy:->proxies' \
15  '(-help)-g[run in graphics mode rather than plain text mode]' \
16  '-help[prints the help screen]' \
17  '(-help)-http-proxy[specify web proxy server]:proxy:->proxies' \
18  '(-help)-image-cache-size[image cache memory]:memory (kilobytes)' \
19  '(-help)-max-connections[maximum number of concurrent connections]:connections' \
20  '(-help)-max-connections-to-host[maximum number of concurrent connection to a given host]:connections' \
21  '(-help)-memory-cache-size[cache memory]:kilobytes' \
22  '(-help)-no-connect[runs links as a separate instance]' \
23  '(-help)-receive-timeout[timeout on receive]:timeout (seconds)' \
24  '(-help)-retries[number of retries]:retries' \
25  '(-help)-source[dump the source page]' \
26  '(-help)-unrestartable-receive-timeout[timeout on non restartable connections]:timeout (seconds)' \
27  '(-help)-version[prints the links version number and exit]' \
28  ':URL:->html' && ret=0
29
30case $state in
31  html)
32    _alternative 'files:file:_files -g "*.x#html(-.)"' 'urls:URL:_urls' && ret=0
33  ;;
34  graphics_drivers)
35    local -a vals
36    vals=( ${=${${${(f)"$(_call_program links-graphics-drivers links -driver help 2>&1)"}[-1]}//','/''}} )
37    _describe -t links-graphics-drivers 'graphics driver' vals && ret=0
38  ;;
39  proxies)
40    local suf=-S:
41    if compset -P '*:'; then
42      _message -e ports 'port number'
43    else
44      compset -S ':*' && suf= 
45      _hosts $suf && ret=0
46    fi
47  ;;  
48esac
49
50return ret
51