28 lines
829 B
Racket
Executable File
28 lines
829 B
Racket
Executable File
#!/usr/bin/env racket
|
|
#lang racket
|
|
|
|
(require racket/runtime-path
|
|
scribble/text (rename-in scribble/text/output [output scribble-output]))
|
|
|
|
(define-runtime-path template "template.rktrkt")
|
|
|
|
(define (eval-template file vars [port (current-output-port)])
|
|
(define cs (current-namespace))
|
|
(define output-exp
|
|
(parameterize ([current-namespace (make-base-namespace)])
|
|
(for ([mod (in-list '(scribble/text))])
|
|
(namespace-attach-module cs mod)
|
|
(namespace-require mod))
|
|
(hash-for-each vars namespace-set-variable-value!)
|
|
(eval `(include/text (file ,file)))))
|
|
(scribble-output output-exp port))
|
|
|
|
|
|
(command-line
|
|
#:program "get-input"
|
|
#:args (day)
|
|
(call-with-output-file
|
|
(format "~a.rkt" day)
|
|
(lambda (out)
|
|
(eval-template (path->string template) (hash 'day day) out))))
|