Compare commits
2 Commits
71c840d687
...
e0260e4496
Author | SHA1 | Date | |
---|---|---|---|
e0260e4496 | |||
836477902c |
28
gem300.rkt
28
gem300.rkt
@@ -29,8 +29,8 @@
|
|||||||
(let ([header (read-line c-in 'return-linefeed)])
|
(let ([header (read-line c-in 'return-linefeed)])
|
||||||
(define-values (status meta)
|
(define-values (status meta)
|
||||||
(let ([status-meta (string-split header " ")])
|
(let ([status-meta (string-split header " ")])
|
||||||
(values (list-ref status-meta 0)
|
(values (car status-meta)
|
||||||
(list-ref status-meta 1))))
|
(string-join (cdr status-meta)))))
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
[(> (string-length status) 2)
|
[(> (string-length status) 2)
|
||||||
@@ -41,3 +41,27 @@
|
|||||||
|
|
||||||
[else
|
[else
|
||||||
(values (string->number status) meta)])))))
|
(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)
|
||||||
|
Reference in New Issue
Block a user