Compare commits

...

2 Commits

Author SHA1 Message Date
e0260e4496 implement very primitive REPL 2025-09-01 16:43:35 -07:00
836477902c correct a minor issue with header parsing 2025-09-01 16:43:05 -07:00

View File

@@ -29,8 +29,8 @@
(let ([header (read-line c-in 'return-linefeed)])
(define-values (status meta)
(let ([status-meta (string-split header " ")])
(values (list-ref status-meta 0)
(list-ref status-meta 1))))
(values (car status-meta)
(string-join (cdr status-meta)))))
(cond
[(> (string-length status) 2)
@@ -41,3 +41,27 @@
[else
(values (string->number status) meta)])))))
(define commands
(list
(cons "default" (lambda (line) (void)))
(cons "go" (lambda (line)
(request line)))))
(define (dispatch-command line)
(let ([split (string-split line " ")])
(let ([cmd (assoc (cond [(null? split) "default"]
[else (first split)])
commands)])
(if cmd
((cdr cmd) (string-join (cdr split)))
(displayln "no such command")))))
(define (repl)
(display "G300> ")
(dispatch-command (read-line))
(repl))
(repl)