#! /usr/bin/env /usr/local/bin/racket #lang racket (require (prefix-in net: "net.rkt") (prefix-in client: "client.rkt")) (define client (new client:client%)) (define (repl) (display "G-300 > ") (flush-output) (with-handlers ([(or/c exn:fail:user? ;; todo: catch these errors separately and reformat them ;; in a user-y way exn:fail:network? net:exn:fail:response?) (λ (exn) (displayln (exn-message exn)))]) (match (regexp-match #px"(\\w+)\\s*(.*)" (read-line (current-input-port) 'any)) [(or (list _ "go" url) (list _ "g" url)) (send client go-cmd url)] [(or (list _ "visit" id) (list _ "v" id)) (send client visit-cmd (string->number id))] [(or (list _ "next" _) (list _ "n" _)) (send client next-cmd)] [(or (list _ "url" id) (list _ "u" id)) (send client url-cmd (string->number id))] [(or (list _ "url") (list _ "u")) (send client url-cmd)] [(list _ "up" _) (send client up-cmd)] [(or (list _ "back" _) (list _ "b" _)) (send client back-cmd)] [(or (list _ "quit" _) (list _ "q" _ )) (exit)] [else (displayln "no such command")])) (repl)) (displayln (string-append "welcome to gem300, a gemini client.\n" "to learn more, type:\n" "'go w6vvn.flounder.online/gem300/tutorial.gmi'")) (flush-output) (repl)