1#compdef surfraw sr
2
3local curcontext="$curcontext" expl state line args ret=1
4
5_arguments -C -A \
6  '-browser=[set browser]:browser:_command_names' \
7  '-elvi[list web sites that can be searched]' \
8  '-escape-url-args=[apply url escaping to arguments]:bool:(yes no)' \
9  '(-g -graphical)'{-g,-graphical}'[get some windowed sin]' \
10  '-help[display help information]' \
11  '-quiet:bool:(yes no)' \
12  '-new[start in a new window]' \
13  '(-t -text)'{-t,-text}'[back to the yellow brick road]' \
14  '(-q -quote)'{-q,-quote}'[quote arguments with quote characters]' \
15  '-version[display version information]' \
16  ':elvi:->elvi' \
17  '*::arg:->subcmd' && ret=0
18
19case $state in
20  subcmd)
21    args=(
22      '-help[display help information]'
23      '*:string:_guard "^-*" "search string"'
24    )
25    case "$words[1]" in
26      ask|cia|cnn|deblogs|excite|filesearching|foldoc|happypenguin|slashdot|slinuxdoc|sundocs|sunsolve|xxx)
27        _message -e string 'search string'
28      ;;
29      alioth)
30        _arguments $args \
31          '-type=-:search type:(soft skill people)' && ret=0
32      ;;
33      altavista)
34        _arguments $args \
35        '-results=-:[number of results to return]' && ret=0
36      ;;
37      amazon)
38        _arguments $args \
39          '-country=-:country code:(uk de fr jp us)' \
40          '-search=-:topic:(all auctions books cars classical \
41            dvd electronics garden kitchen music \
42            outlet photo software toys tools \
43            vhs videogames zshops wireless)' && ret=0
44      ;;
45      austlii)
46        _arguments $args \
47          '-method=-:search method:(any all phrase title boolean)' \
48          '-results=-:[number of results to return]:number' && ret=0
49      ;;
50      bbcnews)
51        _arguments $args \
52          '-scope=-:search scope:(world uk)' && ret=0
53      ;;
54      cddb)
55        _arguments $args \
56          '-artists[search artists]' \
57          '-albums[search albums]' \
58          '-songs[search songs]' \
59          '-all[search all artists, albums and songs]' && ret=0
60      ;;
61      cite)
62        _arguments \
63          '-results=-:[number of results to return]' \
64          '*:search string' && ret=0
65      ;;
66      ctan)
67	_arguments $args \
68	'-name[search by filename]' \
69	'-desc[search descriptions (default)]'\
70	'-doc[search documentation]'
71      ;;
72      currency)
73        _arguments \
74          '-l[list all known currency symbols]' \
75          '-from=-:currency symbol:(EUR USD GBP CAD AUD JPY INR NZD CHF ZAR)' \
76          '-to=-:currency symbol:(EUR USD GBP CAD AUD JPY INR NZD CHF ZAR)' \
77          '*:currency amount' && ret=0
78      ;;
79      cve)
80        _message -e numbers 'CVE Number'
81      ;;
82      debbugs)
83        _arguments \
84          '-search=:search type:(pkg src bug maint tag submitter severity tag)' \
85          '-arc[show archived bugs]' \
86          '-raw[do not sort by status or severity]' \
87          '-rb[reverse order of bugs shown]' \
88          '-rst[reverse order of statuses shown]' \
89          '-rse[reverse order of severities shown]' \
90          '-merge[sisplay merged bugs only once]' \
91          '-nohead[so not show table of contents header]' \
92          '-nofoot[so not show statistics in the footer]' \
93          '-mbox[view results in mbox format]' \
94          '-incstat=-[include given status list]:status:_values -s , status open
95              forwarded pending fixed done' \
96          '-exstat=-[exclude given status list]:status:_values -s , status open
97              forwarded pending fixed done' \
98          '-incsev=-[include given severities]:severity:_values -s , severity
99              critical grave serious important normal minor wishlist fixed' \
100          '-exsev=-[exclude given severities]:severity:_values -s , severity
101              critical grave serious important normal minor wishlist fixed' \
102          '-inctag=-[include given tags]:tag:_values -s , tag potato woody sarge
103              sarge-ignore sid experimental confirmed d-i fixed
104              fixed-in-experimental fixed-upstream help moreinfo patch pending
105              security unreproducible upstream wontfix' \
106          '-extag=-[exclude given tags]:tag:_values -s , tag potato woody sarge
107              sarge-ignore sid experimental confirmed d-i fixed
108              fixed-in-experimental fixed-upstream help moreinfo patch pending
109              security unreproducible upstream wontfix' \
110          '*:package:_deb_packages avail' && ret=0
111        ;;
112      debcontents)
113        _arguments \
114          '-arch=-[search specific architecture]:architecture:(i386 m68k alpha sparc powerpc arm)' \
115          '-distro=-[search specific distribution]:distribution:(stable testing unstable)' \
116          '*:package:_deb_packages avail' && ret=0
117      ;;
118      deblists)
119        _arguments $args \
120          '-shelp[go to search help page]' \
121          '-results=-[specify number of results to return]:number' \
122          '-dates=-[quarters to search]:date' \
123          '-case[use case sensitive search]' \
124          '-errors=-[specify errors allowed]:errors:(0 1 2 best)' \
125          '-partial[allow partial matches]' \
126          '-sameline[semi-colon separated words must appear on same line]' \
127          '-lines=-[specify maximum lines per message]:lines:(0 5 10 50 100)' \
128          '-list=-[specify list to search]:list:(68k accessibility admintool
129              alpha amd64 announce apache arm autobuild beowulf books boot bsd
130              cd cd-vendors cdwrite changes chinese chinese-big5 chinese-gb
131              commercial consultants ctte curiosa custom dak debbugs deity
132              desktop devel devel-announce devel-changes devel-french
133              devel-games devel-italian devel-m68k-changes devel-portuguese
134              devel-powerpc-changes devel-s390-changes devel-spanish
135              devel-sparc-changes doc dpkg edu emacsen embedded esperanto
136              events-eu events-na faq firewall french gcc glibc gtk-gnome hams
137              handheld hppa hurd i18n ia64 ipv6 isp italian japanese java jr kde
138              kernel l10n-arabic l10n-catalan l10n-czech l10n-danish l10n-dutch
139              l10n-english l10n-finnish l10n-french l10n-german l10n-greek
140              l10n-hungarian l10n-italian l10n-korean l10n-polish
141              l10n-portuguese l10n-romanian l10n-russian l10n-spanish
142              l10n-turkish laespiral laptop lcs-eng legal lex lint-maint lsb
143              lsb-confcall lsb-discuss lsb-impl lsb-spec lsb-test med mentors
144              mips mirrors multimedia newmaint newmaint-admin newmaint-discuss
145              news news-french news-german news-portuguese nonprofit ocaml-maint
146              openoffice parisc perl pilot policy pool powerpc project publicity
147              python qa qa-packages qa-private qt-kde release ruby russian s390
148              s390-changes security security-announce sgml simplified-chinese
149              snapshots sparc sparc-changes spi-announce spi-general ssh superh
150              testing tetex-maint toolchain ultralinux user user-catalan
151              user-danish user-de user-french user-german user-icelandic
152              user-indonesian user-polish user-portuguese user-spanish
153              user-swedish user-turkish user-ukrainian vgui-discuss vote win32
154              wnpp women www x)' && ret=0
155      ;;
156      debpackages)
157        _arguments \
158          '-release=-:search release:(all main non-US contrib non-free)' \
159          '-distro=-:search distribution:(all stable testing unstable)' \
160          '*:package:_deb_packages avail' && ret=0
161      ;;
162      debpts)
163        _arguments $args \
164          '-doc[view PTS documentation]' && ret=0
165      ;;
166      debsec)
167        _message -e string 'package name, bug number or CVE ID'
168      ;;
169      deja)
170        _arguments $args \
171          '-results=-:[number of results to return]' \
172          '-m[search for Message-ID]' && ret=0
173      ;;
174      dmoz)
175        _arguments $args \
176          '-cat=-[specify category]:category:(All Arts Business Computers Games
177              Health Home Kids_and_Teens News Recreation Reference Regional
178              Science Shopping Society Sports World Adult)' \
179          '-type=-:type:((c\:categories\ only s\:sites\ only b\:both))' \
180          '-kids[sites for kids]' \
181          '-teens[sites for teens]' \
182          '-mteens[sites for mature teens]' && ret=0
183      ;;
184      ebay)
185        _arguments $args \
186          '-country=-:country:(com de uk fr)' \
187          '-results=-:[number of results to return]:number' && ret=0
188      ;;
189      etym)
190        _wanted dictword expl 'dictionary word' \
191           compadd $(look "${PREFIX}") && ret=0
192      ;;
193      fast)
194        _arguments $args \
195          '-type=-:search type:(all any phrase)' && ret=0
196      ;;
197      freebsd)
198        _arguments $args \
199          '-mail=-[search mailing lists]:enable:(yes no)' \
200          '-gg=-[search [Google Groups]:enable:(yes no)' \
201          '-pr=-[query problem reports]:enable:(yes no)' \
202          '-cvs=-[query cvsweb]:enable:(yes no)' \
203          '-mid=-[query mailing lists by Message-ID]:enable:(yes no)' \
204          '-ps=-[go to the port survey page]:enable:(yes no)' \
205          '-prs=-[go to the problem report survey page]:enable:(yes no)' \
206          '-elogs=-[go to the build error logs page]:enable:(yes no)' && ret=0
207      ;;
208      freedb)
209        _arguments $args \
210          '-artists[search artists]' \
211          '-albums[search albums]' \
212          '-songs[search songs]' \
213          '-rest[search the rest of the data]' \
214          '-all[search all fields]' \
215          '-bycat[sort results by category]' \
216          '*-cat=-:category:(all blues classical country data folk
217              jazz misc newage reggae rock soundtrack)' && ret=0
218      ;;
219      freshmeat)
220        _deb_packages avail && ret=0
221      ;;
222      fsfdir)
223	_arguments $args
224      ;;
225      google)
226        _arguments $args \
227          '(-l --lucky)'{-l,--lucky}'[feeling lucky?]' \
228          '-results=-:[number of results to return]:' \
229          '-search=-:topic:(bsd linux mac unclesam)' && ret=0
230      ;;
231      gutenberg)
232	_arguments $args \
233	  '-title[search titles (default)]'
234	  '-author[search authors]'
235	  '-num[search etext numbers]'
236      ;;
237      imdb)
238        _arguments $args \
239          '-category=-:category:(All Titles MyMovies People Characters Quotes Bios Plots)' && ret=0
240      ;;
241      ixquick)
242	_arguments $args \
243	  '-search=-:search type:(web pics)' \
244	  '-lang=-:language:(english dansk deutsch espanol francais italiano nederlands norsk polski portugues suomi svenska turkce jiantizhongwen nihongo fantizhengwen hangul)'
245      ;;
246      jake)
247        _arguments $args \
248          '-method=-:search type:(title issn)' \
249          '-volume=-:volume' \
250          '-issue=-:issue' \
251          '-spage=-:start page' \
252          '-epage=-:end page' \
253          '-year=-:year' && ret=0
254      ;;
255      leodict)
256        _arguments \
257          '-tol=:special character tolerance:(off standard high)' \
258          '-to=:language:(de en either)' \
259          '-lang=:webpage is in this language:(en de)' \
260          '-link=:link results:(on off)' \
261          '-head=:display headlines:(on off)' \
262          '-grid=:show results in grid:(on off)' \
263          '-spell=:spelling tolerance:(off standard force)' \
264          '*:dictionary word:->dictword' && ret=0
265
266        [[ "$state" = dictword ]] && _wanted words expl 'dictionary word' \
267            compadd $(look "${PREFIX}") && ret=0
268      ;;
269      netbsd|openbsd)
270        _arguments $args \
271          '-mail=-[search mailinglists]:enable:(no yes)' \
272          '-pr=-[query problem reports]:enable:(no yes)' && ret=0
273      ;;
274      pgpkeys)
275        _arguments \
276          '-s[display key signatures]' \
277          '*:key ID or email' && ret=0
278      ;;
279      pubmed)
280        _arguments $args \
281          '-db=-:[specify database]:database:(PubMed Nucleotide Protein Genome
282              Structure Popset)' && ret=0
283      ;;
284      rfc)
285        _arguments $args \
286          '-results=-:[specify number of results to return]:number' \
287          '-pdf[return files as PDFs]' \
288          '-rev[reverse order of results]' \
289          '-exact[match exact words (instead of prefixes)]' \
290          '-abs[show abstracts]' \
291          '-keywords[show keywords]' \
292          "-nodirect[don't try and go direct to RFC]" \
293          '-ftp[retrieve RFCs via FTP instead of HTTP]' \
294          '-field=-:search field:(all number title author keyword)' \
295          '-search=-:collection:(all rfc std bcp fyi)' && ret=0
296      ;;
297      scaleplus)
298        _arguments $args \
299          '-results=-:[number of results to return]' && ret=0
300      ;;
301      sourceforge)
302        _arguments \
303          '-exact=-[require all words}:enable:(yes no)' \
304          '-type=:search type:(soft people freshmeat)' \
305          '*:project:_deb_packages avail' && ret=0
306      ;;
307      stockquote)
308          _arguments $args \
309          '-provider=-[select quote provider]:provider:(yahoo nasdaq quote)' && ret=0
310      ;;
311      thesaurus|webster)
312        _wanted words expl 'word' compadd $(look "${PREFIX}") && ret=0
313      ;;
314      rae)
315        _wanted dictionary expl 'palabra diccionario' \
316            compadd $(look "${PREFIX}") && ret=0
317      ;;
318      translate)
319        _arguments \
320          '-from=-:language:(de en es fr it ja ko pt ru zh)' \
321          '-to=-:language:(de en es fr it ja ko pt ru zh)' \
322          '-provider=-[select translation service provider]:provider:(raging bablefish)' \
323          '*:dictionary word:->dictword' && ret=0
324
325        [[ "$state" = dictword ]] && _wanted words expl 'dictionary word' \
326            compadd $(look "${PREFIX}") && ret=0
327      ;;
328      rhyme)
329        _arguments \
330          '-method=-:type of word correlation:(perfect syn hom cons rel sub spell pic shake def)' \
331          '*:dictionary word:->dictword' && ret=0
332
333        [[ "$state" = dictword ]] && _wanted words expl 'dictionary word' \
334            compadd $(look "${PREFIX}") && ret=0
335      ;;
336      w3css)
337        _arguments \
338          '-warnings=-[specify level of warnings displayed]:warning level:(all normal important none)' \
339          '-profile=-:CSS profile:(none css1 css2 css3 svg svgbasic svgtiny mobile atsv-tv tv)' \
340          '-medium=-:user medium:(all aural braille embossed handheld print projection
341              screen tty tv presentation)' \
342          :URL:_urls && ret=0
343      ;;
344      w3html)
345        _arguments \
346          '-usage[go to validator help page]' \
347          '-encoding=-[set page encoding]' \
348          '-encfb[fall back to encoding rather than override]' \
349          '-doctype=-":[set page doctype]:' \
350          '-docfb[fall back to doctype rather than override]' \
351          '-nv[be less verbose]' \
352          '-showsource[show page source]' \
353          '-showoutline[show page outline (headings)]' \
354          '-showparsetree[show parse tree]' \
355          '-excludeatt[exclude attributes from parse tree]' \
356          '-err[validate Error (404) pages]' \
357          :URL:_urls && ret=0
358        ;;
359      w3link)
360        _arguments \
361          '-r[check linked documents recursively]' \
362          '-d=-[recursion depth]:depth' \
363          '-s[summary only]' \
364          '-hiderd[hide redirects]' \
365          '-dhiderd[hide redirects for directories only]' \
366          "-nolang[don't send the Accept-Language: header]" \
367          '-cookie[save options in a cookie]' \
368          :URL:_urls && ret=0
369      ;;
370      w3rdf)
371        _arguments \
372          '-output=-:output type:(Triples Graphs Both)' \
373          '-format=-:graph format:(PNG_EMBED PNG_LINK SVG_LINK SVG_EMBED
374              GIF_EMBED \ GIF_LINK PS_LINK HP_PCL_LINK HP_GL_LINK ISV_ZVTM)' \
375          '-savedot[save GraphViz DOT file]' \
376          '-ntriples[display triples in N-Triples format]' \
377          '-embedded[RDF is not enclosed in <RDF> tags]' \
378          '-useme[grant w3c permission to save the RDF for developing test cases]' \
379          '-anon[make anonymous nodes unlabelled]' \
380          '-fontsize=-:font Size:(10 12 14 16 20)' \
381          '-orient=-:orientation:(TB LR)' \
382          '-node=-:node Colour:(Black Blue Darkgreen Red)' \
383          '-nodetext=-[node text color]:color:(Black Blue Darkgreen Red)' \
384          '-arc=-[arc color]:color:(Black Blue Darkgreen Red)' \
385          '-arctext=-:[arc text color]:color:(Black Blue Darkgreen Red)' \
386          :URL:_urls && ret=0
387      ;;
388      wayback)
389	_arguments $args \
390	  '-syear=-[start search from this year]:year' \
391	  '-smonth=-:[start search from this month]:month:(jan feb mar apr may jun jul aug sep oct nov dec)' \
392	  '-sday=-[start search from this day]:number' \
393	  '-eyear=-[end search in this year]:year' \
394	  '-emonth=-[end search in this month]:month:(jan feb mar apr may jun jul aug sep oct nov dec)' \
395	  '-eday=-[end search in this day]:number' \
396	  '-list[list all pages that match search criteria]' \
397	  '-dups[show dups]' \
398	  '-compare[compare pages]' \
399	  '-pdf[show as PDF]' \
400	  '-alias=-[how to handle site aliases]:alias:(merge show hide)' \
401	  '-redir=-[how to handle redirections]:redir:(hide flag show)' \
402	  '-type=-[file type to search for]:type:(image audio video binary text pdf)'
403      ;;
404      wetandwild)
405        _arguments \
406          '-city=-[town or City or (US only) zipcode]:' \
407          '-country=-[two letter domain-style country code]:' \
408          '-state=-[specify state, province or region]:state' && ret=0
409      ;;
410      wikipedia)
411        _arguments $args \
412          '-language=-:[two letter language code]:' && ret=0
413        ;;
414      woffle)
415        _arguments $args \
416          '-method=-:search method:(and or bool)' \
417          '-format=-:result format:(short long)' \
418          '-sort=-:sort method:(score revscore time revtime title revtitle)' && ret=0
419      ;;
420      yahoo)
421          _arguments $args \
422          '-results=-[specify number of results to return]:number' && ret=0
423      ;;
424      yubnub)
425        _message -e command 'Yubnub Command'
426      ;;
427    esac
428  ;;
429  elvi)
430    _wanted elvi expl elvi compadd \
431      ${${${(f)"$(_call_program elvi surfraw -elvi)"}%%[[:space:]]##--*}%:*} && ret=0
432  ;;
433esac
434
435return ret
436