28 lines
688 B
Racket
28 lines
688 B
Racket
#lang racket
|
|
|
|
(require (prefix-in client: "client.rkt"))
|
|
|
|
(define client (new client:client%))
|
|
|
|
(define (repl)
|
|
(display "G-300 > ")
|
|
|
|
(let ([matches (regexp-match #px"(\\w+)\\s*(.*)" (read-line))])
|
|
(cond
|
|
;; next command. also default
|
|
[(or (not matches)
|
|
(string=? (cadr matches) "next")
|
|
(string=? (cadr matches) "n"))
|
|
(send client next-cmd)]
|
|
|
|
;; go command
|
|
[(or (string=? (cadr matches) "go")
|
|
(string=? (cadr matches) "g"))
|
|
(send client go-cmd (caddr matches))]
|
|
|
|
;; visit link command
|
|
[(andmap char-numeric? (string->list (cadr matches)))
|
|
(send client visit-cmd (cadr matches))]))
|
|
|
|
(repl))
|