hyper-literate/collects/help/help.ss
Eli Barzilay 43e5913612 Lots of fixes & improvements for help
svn: r8561

original commit: 0cd1cc4b08276c41216c4b73895bfa1acb52eb59
2008-02-07 07:59:59 +00:00

32 lines
1.1 KiB
Scheme

#lang scheme/base
(require "search.ss" scheme/cmdline)
(define go-if-one? #t)
(define exact-search? #f)
(define regexp-search? #f)
(command-line
#:once-any
[("--go" "-g") "Go directly to search result if only one (default)"
(set! go-if-one? #t)]
[("++go" "+g") "Show search results page even if only one result"
(set! go-if-one? #t)]
#:once-each
[("--exact" "-x") "Search for the given term exactly"
(set! exact-search? #t)]
[("--regexp" "-r") "Search for the given regexp"
(set! regexp-search? #t)]
#:args search-terms
(let ([one? (= 1 (length search-terms))])
(cond [(and regexp-search? (not one?))
(error 'plt-help "expected a single regexp after -r or --regexp")]
[(and exact-search? (not one?))
(error 'plt-help "expected a single search term after -x or --exact")]
[(null? search-terms) (send-main-page)]
[else (perform-search (if regexp-search?
(list (regexp (car search-terms)))
search-terms)
#:exact? (or exact-search? regexp-search?)
#:go-if-one? go-if-one?)])))