48 lines
1.5 KiB
Racket
48 lines
1.5 KiB
Racket
#lang racket/base
|
|
|
|
(require racket/file racket/path racket/pretty
|
|
"compiler.rkt" "render.rkt" "util.rkt")
|
|
|
|
(provide init-project)
|
|
|
|
(define (init-project name [dir (build-path (current-directory) name)])
|
|
(when (directory-exists? dir)
|
|
(error "directory already exists!" (path->string dir)))
|
|
(define src (simple-form-path (build-path dir "src")))
|
|
(define target (simple-form-path (build-path dir "target")))
|
|
(make-directory* src)
|
|
(with-output-to-file
|
|
(build-path src "index.md")
|
|
(λ ()
|
|
(pretty-write
|
|
(list (list 'title name)
|
|
(list 'summary "a cool site")
|
|
(apply list 'date (get-date-ymd))
|
|
(list 'tags "tag1" "tag2")
|
|
(list 'lang "en")
|
|
(list 'authors "you")))
|
|
(write-string "\n# trans rights\n\nmeow")))
|
|
(with-output-to-file
|
|
(build-path src "index.scss")
|
|
(λ () (write-string "/* your cool SCSS goes here */")))
|
|
(with-output-to-file
|
|
(build-path src "favicon.png.rkt")
|
|
(λ () (write-string "#lang capybara/pict\n\n(standard-cat 128 128)")))
|
|
(with-output-to-file
|
|
(build-path src "config.rktd")
|
|
(λ () (pretty-write (list (list 'base (path->string target))))))
|
|
|
|
(parameterize ([current-directory dir])
|
|
(generate/execute (scan-for-rules)))
|
|
|
|
(void))
|
|
|
|
(module+ main
|
|
(require racket/cmdline)
|
|
(command-line
|
|
#:program "capybara-init"
|
|
#:args (name)
|
|
(with-handlers ([exn? (λ (e) (printf "error: ~a\n" (exn-message e)))])
|
|
(init-project name)
|
|
(printf "created project ~a\n" name))))
|