diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/reference/cmdline.scrbl b/pkgs/racket-pkgs/racket-doc/scribblings/reference/cmdline.scrbl index 534d2ac6d8..ae2e4aee15 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/reference/cmdline.scrbl +++ b/pkgs/racket-pkgs/racket-doc/scribblings/reference/cmdline.scrbl @@ -17,6 +17,7 @@ (code:line #:once-each flag-spec ...) (code:line #:once-any flag-spec ...) (code:line #:final flag-spec ...) + (code:line #:usage-help string ...) (code:line #:help-labels string ...) (code:line #:ps string ...)] [flag-spec (flags id ... help-spec body ...+) @@ -140,6 +141,10 @@ handler procedure and help string list returned by @racket[handler-expr] and @racket[help-expr] are used as in the @racket[_table] argument of @racket[parse-command-line]. +A @racket[#:usage-help] clause inserts text lines immediately after +the usage line. Each string in the clause provides a separate line +of text. + 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. @@ -265,12 +270,13 @@ 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], @racket['help-labels], or @racket['ps] with the same meanings as -the corresponding clause tags in @racket[command-line]. 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: +@racket['final], @racket['help-labels], @racket['usage-help], or +@racket['ps] with the same meanings as the corresponding clause tags +in @racket[command-line]. For the @racket['help-labels], +@racket['usage-help] or @racket['ps] mode, a list of help strings 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: @itemize[ diff --git a/racket/collects/racket/cmdline.rkt b/racket/collects/racket/cmdline.rkt index 06b645aacc..b41c4139f8 100644 --- a/racket/collects/racket/cmdline.rkt +++ b/racket/collects/racket/cmdline.rkt @@ -64,6 +64,14 @@ (let ([a (syntax-e (car lst))] [pieces (up-to-next-keyword (cdr lst))]) (case a + [(#:usage-help) + (for ([x (in-list pieces)]) + (unless (string? (syntax-e x)) + (serror "#:usage-help clause contains non-string" + x))) + (loop (at-next-keyword (cdr lst)) + (cons (list* #'list #`(quote usage-help) pieces) + accum))] [(#:help-labels) (for ([x (in-list pieces)]) (unless (string? (syntax-e x)) @@ -243,11 +251,11 @@ (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 ps)) - (bad-table "spec-set type must be 'once-any, 'once-each, 'multi, 'final, 'help-labels, or 'ps: ~a" + (unless (memq (car spec) '(once-any once-each multi final help-labels usage-help ps)) + (bad-table "spec-set type must be 'once-any, 'once-each, 'multi, 'final, 'help-labels, 'usage-help, or 'ps: ~a" (car spec))) (for ([line (in-list (cdr spec))]) - (if (memq (car spec) '(help-labels ps)) + (if (memq (car spec) '(help-labels ps usage-help)) (unless (string? line) (bad-table "~a line must be a string: ~e" (car spec) line)) (begin @@ -338,9 +346,13 @@ (let ([sp (open-output-string)]) (fprintf sp "~a [