123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #!/usr/bin/env gosh
- (import
- (scheme base)
- (scheme read)
- (scheme file)
- (scheme write)
- (scheme process-context)
- (file util)
- (only (gauche base) port->string)
- (srfi 28))
- (define cli-args (command-line))
- (unless (> (length cli-args) 1)
- (error "gen-problem" "Need at least 1 argument"))
- (define id (list-ref (command-line) 1))
- (define test-file-in (open-input-file "test-template.scm"))
- (define make-file-in (open-input-file "Makefile-template.txt"))
- (define soln-file-in (open-input-file "solution-template.scm"))
- (define test-file-content (format (port->string test-file-in) id id))
- (define make-file-content (format (port->string make-file-in) id))
- (define soln-file-content (format (port->string soln-file-in) id))
- (close-input-port test-file-in)
- (close-input-port make-file-in)
- (close-input-port soln-file-in)
- (make-directory* id)
- (define test-file-out (open-output-file (string-append id "/test.scm")))
- (define make-file-out (open-output-file (string-append id "/Makefile")))
- (define soln-file-out (open-output-file (string-append id "/solution.scm")))
- (display test-file-content test-file-out)
- (display make-file-content make-file-out)
- (display soln-file-content soln-file-out)
- (close-output-port test-file-out)
- (close-output-port make-file-out)
- (close-output-port soln-file-out)
|