;; ;; %%HEADER%% ;; (use chickumber args files posix chicken-syntax) (cond-expand (development (load "chickumber.scm") (load "chickumber-server.scm") (import chickumber chickumber-server)) (else (use chickumber chickumber-server))) (define opts (list (args:make-option (p port) (required: "PORT") (sprintf "port to bind on [default: ~A]" +default-port+)))) (define (usage) (with-output-to-port (current-error-port) (lambda () (print "Usage: " (car (argv)) " [options] stepfiles ...") (newline) (print (args:usage opts)))) (exit 1)) (define (discover-step-files arguments) (let loop ((arguments arguments) (step-files '())) (if (null? arguments) step-files (let ((full-path (absolutize-path (car arguments)))) (if (directory? full-path) (loop (cdr arguments) (add-files-from-directory full-path step-files)) (loop (cdr arguments) (cons full-path step-files))))))) (define (add-files-from-directory directory step-files) (fold cons step-files (glob (conc directory "/*.scm")))) (define (absolutize-path path) (if (absolute-pathname? path) (normalize-pathname path) (normalize-pathname (conc (current-directory) "/" path)))) (define (main) (when (= (length (argv)) 1) (usage)) (receive (options operands) (args:parse (command-line-arguments) opts) (when (null? operands) (usage)) (start-wire-server (discover-step-files operands) (string->number (or (alist-ref 'port options) "50000"))))) (main)