new 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env gosh
  2. (import
  3. (scheme base)
  4. (scheme read)
  5. (scheme file)
  6. (scheme write)
  7. (scheme process-context)
  8. (file util)
  9. (only (gauche base) port->string)
  10. (srfi 28))
  11. (define cli-args (command-line))
  12. (unless (> (length cli-args) 1)
  13. (error "gen-problem" "Need at least 1 argument"))
  14. (define id (list-ref (command-line) 1))
  15. (define test-file-in (open-input-file "test-template.scm"))
  16. (define make-file-in (open-input-file "Makefile-template.txt"))
  17. (define soln-file-in (open-input-file "solution-template.scm"))
  18. (define test-file-content (format (port->string test-file-in) id id))
  19. (define make-file-content (format (port->string make-file-in) id))
  20. (define soln-file-content (format (port->string soln-file-in) id))
  21. (close-input-port test-file-in)
  22. (close-input-port make-file-in)
  23. (close-input-port soln-file-in)
  24. (make-directory* id)
  25. (define test-file-out (open-output-file (string-append id "/test.scm")))
  26. (define make-file-out (open-output-file (string-append id "/Makefile")))
  27. (define soln-file-out (open-output-file (string-append id "/solution.scm")))
  28. (display test-file-content test-file-out)
  29. (display make-file-content make-file-out)
  30. (display soln-file-content soln-file-out)
  31. (close-output-port test-file-out)
  32. (close-output-port make-file-out)
  33. (close-output-port soln-file-out)