#!/usr/bin/env racket #lang racket (require racket/runtime-path scribble/text (rename-in scribble/text/output [output scribble-output]) "aoc-lib.rkt") (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 "make-day" #:args (day) ;; make solution file (call-with-output-file (format "~a.rkt" day) (lambda (out) (eval-template (path->string template) (hash 'day day) out))) ;; get input (define in (aoc-fetch-input (getenv "AOC_YEAR") day (getenv "AOC_SESSION"))) (call-with-output-file (build-path "inputs" day) (lambda (out) (copy-port in out))))