support multiple server ports

pull/9/head
Matthew Butterick 11 years ago
parent f3e5e4324b
commit b2a27cd4df

@ -9,12 +9,13 @@ render renders all files in project directory
clone copies rendered files to desktop
[filename] renders individual file"))
(define (handle-start directory)
(define (handle-start directory [port #f])
(if (not (directory-exists? directory))
(error (format "~a is not a directory" directory))
`(begin
(require pollen/server pollen/world)
(parameterize ([world:current-project-root ,directory])
(parameterize ([world:current-project-root ,directory]
,@(if port (list `(world:current-server-port ,port)) null))
(start-server)))))
(define (handle-else command)

@ -6,10 +6,15 @@
(define-for-syntax args (current-command-line-arguments))
(define-for-syntax arg-command-name (with-handlers ([exn:fail? (λ(exn) #f)]) (vector-ref args 0)))
(define-for-syntax arg-project-directory
(with-handlers ([exn:fail? (λ(exn) (current-directory))])
(path->complete-path (simplify-path (string->path (vector-ref args 1))))))
(define-for-syntax arg-server-port
(with-handlers ([exn:fail? (λ(exn) #f)])
(string->number (vector-ref args 2))))
(define-for-syntax (command-error error-string)
`(displayln (string-append "Error: ", error-string)))
@ -19,7 +24,7 @@
(datum->syntax stx
(case arg-command-name
[(#f "help") (handle-help)]
[("start") (handle-start arg-project-directory)]
[("start") (handle-start arg-project-directory arg-server-port)]
[else (handle-else arg-command-name)])))
(select-syntax-for-command)

Loading…
Cancel
Save