You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
typesetting/quad/fontproof/command.rkt

59 lines
2.2 KiB
Racket

4 years ago
#lang debug racket
(require "main.rkt")
(module+ raco
4 years ago
;; pull text out of stdin, if any
;; todo: make this cooperate with `read` for confirmation of replace
(define text (string-join (for/list ([t (in-port read)])
(format "~a" t)) " "))
4 years ago
(define command-name (with-handlers ([exn:fail? (λ (exn) #f)])
(vector-ref (current-command-line-arguments) 0)))
4 years ago
(dispatch command-name text))
4 years ago
(module+ main
(println "this is fontproof command"))
4 years ago
(define (dispatch command-name text)
4 years ago
(when (positive? (vector-length (current-command-line-arguments)))
(define output-file-path #false)
(define page-size #false)
(define font-sizes #false)
(define line-heights #false)
4 years ago
(define doc #false)
(define replace #false)
4 years ago
(define families
4 years ago
(command-line
#:program "fontproof"
#:argv (current-command-line-arguments)
#:once-each
[("-p" "--page") page-size-arg
"page size"
(set! page-size page-size-arg)]
[("-r" "--replace") "replace existing"
(set! replace #true)]
[("-d" "--doc") doc-arg
"sample text"
(set! doc doc-arg)]
[("-o" "--output") output-file-path-arg
"output file path"
(set! output-file-path output-file-path-arg)]
[("-s" "--size") font-sizes-arg
"font sizes"
(set! font-sizes font-sizes-arg)]
[("-l" "--leading") line-heights-arg
"font size"
(set! line-heights line-heights-arg)]
#:args families
families))
(cond
[(null? families) (displayln "no family given")]
[else (for ([family (in-list families)])
(make-proof family (if (non-empty-string? text) text doc)
#:page-size page-size
#:font-sizes font-sizes
#:line-heights line-heights
#:output-file-path output-file-path
#:replace replace))])))
4 years ago