Skip to content

Commit

Permalink
Use OS Kernel 22.0 launcher feature for command line handling
Browse files Browse the repository at this point in the history
  • Loading branch information
doublec committed Sep 28, 2019
1 parent d761c2c commit bd2a994
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 39 deletions.
1 change: 1 addition & 0 deletions driver.ms
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
(kl:set (quote *language*) "Wasp Lisp")
(kl:set (quote *implementation*) "WaspVM")
(kl:set (quote *port*) "0.11")
(kl:set (quote *release*) "0.11")
(kl:set (quote *porters*) "Chris Double")
(kl:set (quote *sterror*) (cons (current-output) #f))
(kl:set (quote *stinput*) (cons (current-input) (make-string)))
Expand Down
40 changes: 1 addition & 39 deletions shen.ms
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,6 @@

(import "shen-lib")

(define (usage)
(println* "Usage: shen [options] [...args...]\n"
" -h, --help : Prints help and exits\n"
" -l, --load <file> : Loads Shen <file>\n"
" -e, --eval <string> : Evaluates <string>\n"
" -r, --repl : Run the REPL, even if -l or -e are provided\n"
"Any additional arguments are passed to the Shen system in\n"
"the variable shen-wasp.*argv*"))

(define (process-load file)
(define contents (kl:read-file file))
(map (lambda (x) (kl:shen.eval-without-macros x)) contents))

(define (process-eval str)
(println* (format (kl:eval (kl:head (kl:read-from-string str))))))

(define (main . args)
(define argv (make-tc))
(define repl #t)
(until (null? args)
(define arg (car args))
(set! args (cdr args))
(cond
((or (string=? arg "--help") (string=? arg "-h"))
(usage)
(set! repl #f))
((or (string=? arg "-l") (string=? arg "--load"))
(set! repl #f)
(process-load (car args))
(define args (cdr args)))
((or (string=? arg "-e") (string=? arg "--eval"))
(set! repl #f)
(process-eval (car args))
(define args (cdr args)))
((or (string=? arg "-r") (string=? arg "--repl"))
(set! repl #t))
(else
(tc-add! argv arg))))
(kl:set (quote shen-wasp.*argv*) (tc->list argv))
(kl:shen.initialise)
(when repl (kl:shen.repl)))
(kl:shen.x.launcher.main (cons "shen" args)))

0 comments on commit bd2a994

Please sign in to comment.