racket/cmdline add `#:ps' clause
This commit is contained in:
parent
a57447cde5
commit
0c303ca9cd
|
@ -72,6 +72,14 @@
|
|||
(loop (at-next-keyword (cdr lst))
|
||||
(cons (list* #'list #`(quote help-labels) pieces)
|
||||
accum))]
|
||||
[(#:ps)
|
||||
(for ([x (in-list pieces)])
|
||||
(unless (string? (syntax-e x))
|
||||
(serror "#:ps clause contains non-string"
|
||||
x)))
|
||||
(loop (at-next-keyword (cdr lst))
|
||||
(cons (list* #'list #`(quote ps) pieces)
|
||||
accum))]
|
||||
[(#:once-each #:once-any #:multi #:final)
|
||||
(let ([sublines
|
||||
(let slloop ([sublines pieces])
|
||||
|
@ -239,13 +247,13 @@
|
|||
(for ([spec (in-list table)])
|
||||
(unless (and (list? spec) (pair? spec))
|
||||
(bad-table "spec-set must be a non-empty list: ~a" spec))
|
||||
(unless (memq (car spec) '(once-any once-each multi final help-labels))
|
||||
(bad-table "spec-set type must be 'once-any, 'once-each, 'multi, 'final, or 'help-labels: ~a"
|
||||
(unless (memq (car spec) '(once-any once-each multi final help-labels ps))
|
||||
(bad-table "spec-set type must be 'once-any, 'once-each, 'multi, 'final, 'help-labels, or 'ps: ~a"
|
||||
(car spec)))
|
||||
(for ([line (in-list (cdr spec))])
|
||||
(if (eq? (car spec) 'help-labels)
|
||||
(if (memq (car spec) '(help-labels ps))
|
||||
(unless (string? line)
|
||||
(bad-table "help-labels line must be a string: ~e" line))
|
||||
(bad-table "~a line must be a string: ~e" (car spec) line))
|
||||
(begin
|
||||
(unless (and (list? line) (= (length line) 3))
|
||||
(bad-table "spec-line must be a list of at three or four items: ~e" line))
|
||||
|
@ -339,7 +347,8 @@
|
|||
(fprintf sp "~a [ <option> ... ]" (program-name program))
|
||||
(print-args sp finish-help finish)
|
||||
(fprintf sp "\n where <option> is one of\n")
|
||||
(for ([set (in-list table)]) ; the original table
|
||||
(for ([set (in-list table)] ; the original table
|
||||
#:unless (eq? (car set) 'ps))
|
||||
(if (eq? (car set) 'help-labels)
|
||||
(for ([line (in-list (cdr set))])
|
||||
(fprintf sp " ~a\n" line))
|
||||
|
@ -382,6 +391,10 @@
|
|||
(fprintf sp " /|\\ Brackets indicate mutually exclusive options.\n"))
|
||||
(fprintf sp " Multiple single-letter switches can be combined after one `-'; for\n")
|
||||
(fprintf sp " example: `-h-' is the same as `-h --'\n")
|
||||
(for ([set (in-list table)] ; the original table
|
||||
#:when (eq? (car set) 'ps))
|
||||
(for ([line (in-list (cdr set))])
|
||||
(fprintf sp " ~a\n" line)))
|
||||
(help (get-output-string sp))))
|
||||
(list "Help")))
|
||||
(for/list ([spec (in-list table)])
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
(code:line #:once-each flag-spec ...)
|
||||
(code:line #:once-any flag-spec ...)
|
||||
(code:line #:final flag-spec ...)
|
||||
(code:line #:help-labels string ...)]
|
||||
(code:line #:help-labels string ...)
|
||||
(code:line #:ps string ...)]
|
||||
[flag-spec (flags id ... help-spec body ...+)
|
||||
(flags => handler-expr help-expr)]
|
||||
[flags flag-string
|
||||
|
@ -143,6 +144,10 @@ A @racket[#:help-labels] clause inserts text lines into the help table
|
|||
of command-line flags. Each string in the clause provides a separate
|
||||
line of text.
|
||||
|
||||
A @racket[#:ps] clause inserts text lines at the end of the help
|
||||
output. Each string in the clause provides a separate
|
||||
line of text.
|
||||
|
||||
After the flag clauses, a final clause handles command-line arguments
|
||||
that are not parsed as flags:
|
||||
|
||||
|
@ -260,9 +265,9 @@ A @racket[table] is a list of flag specification sets. Each set is
|
|||
represented as a pair of two items: a mode symbol and a list of either
|
||||
help strings or flag specifications. A mode symbol is one of
|
||||
@racket['once-each], @racket['once-any], @racket['multi],
|
||||
@racket['final], or @racket['help-labels], with the same meanings as
|
||||
@racket['final], @racket['help-labels], or @racket['ps] with the same meanings as
|
||||
the corresponding clause tags in @racket[command-line]. For the
|
||||
@racket['help-labels] mode, a list of help string is provided. For the
|
||||
@racket['help-labels] or @racket['ps] mode, a list of help string is provided. For the
|
||||
other modes, a list of flag specifications is provided, where each
|
||||
specification maps a number of flags to a single handler procedure. A
|
||||
specification is a list of three items:
|
||||
|
|
|
@ -4,6 +4,7 @@ Added raise-argument-error, raise-result-error,
|
|||
raise-arguments-error, raise-range-error
|
||||
racket/contract: added procedure-arity-includes/c
|
||||
racket/sandbox: added sandbox-propagate-exceptions
|
||||
racket/cmdline: add #:ps for command-line
|
||||
Changed impersonate-struct so that accessor impersonation requires
|
||||
work only if the field is accessible via the current impersonator
|
||||
or a mutator for the same field is also impersonated
|
||||
|
|
Loading…
Reference in New Issue
Block a user