start command: display [<dir>] and [<port>] in help text

pull/242/head
Bogdan Popa 4 years ago
parent 0e87a6e1c2
commit c25cd94b53
No known key found for this signature in database
GPG Key ID: 4227ABAD6F9D03D5

@ -175,21 +175,23 @@ version print the version" (current-server-port) (make-publish-di
(define (handle-start) (define (handle-start)
(define launch-wanted #f) (define launch-wanted #f)
(define localhost-wanted #f) (define localhost-wanted #f)
(define clargs (define-values (dir http-port)
(command-line #:program "raco pollen start" (command-line
#:argv (vector-drop (current-command-line-arguments) 1) ; snip the 'start' from the front #:program "raco pollen start"
#:once-each #:argv (vector-drop (current-command-line-arguments) 1) ; snip the 'start' from the front
[("--launch" "-l") "Launch browser after start" (set! launch-wanted #t)] #:once-each
[("--local") "Restrict access to localhost" (set! localhost-wanted #t)] [("--launch" "-l") "Launch browser after start" (set! launch-wanted #t)]
#:args other-args [("--local") "Restrict access to localhost" (set! localhost-wanted #t)]
other-args)) #:args ([dir (current-directory)] [port "8080"])
(define dir (path->directory-path (get-first-arg-or-current-dir clargs))) (define parsed-dir
(unless (directory-exists? dir) (path->directory-path (normalize-path (very-nice-path dir))))
(error (format "~a is not a directory" dir))) (unless (directory-exists? parsed-dir)
(define http-port (with-handlers ([exn:fail? (λ (e) #f)]) (error (format "~a is not a directory" parsed-dir)))
(string->number (cadr clargs))))
(when (and http-port (not (exact-positive-integer? http-port))) (define parsed-port (string->number port))
(error (format "~a is not a valid port number" http-port))) (when (and parsed-port (not (exact-positive-integer? parsed-port)))
(error (format "~a is not a valid port number" parsed-port)))
(values parsed-dir parsed-port)))
(parameterize ([current-project-root dir] (parameterize ([current-project-root dir]
[current-server-port (or http-port (setup:project-server-port))] [current-server-port (or http-port (setup:project-server-port))]
[current-server-listen-ip (and localhost-wanted "127.0.0.1")] [current-server-listen-ip (and localhost-wanted "127.0.0.1")]

Loading…
Cancel
Save