implement some guards on the client. definitely need to relearn how to do syntax macros now...
This commit is contained in:
19
client.rkt
19
client.rkt
@@ -30,6 +30,10 @@
|
||||
(super-new)
|
||||
|
||||
(define/public (up-cmd)
|
||||
(if (null? current-url)
|
||||
|
||||
(displayln "you need to 'go' somewhere first!")
|
||||
|
||||
(if (string=? (path->string
|
||||
(simplify-path
|
||||
(url->path current-url)))
|
||||
@@ -42,7 +46,7 @@
|
||||
(build-path (url->path current-url) 'up)
|
||||
#f)])
|
||||
(get (struct-copy url current-url
|
||||
[path (url-path (path->url parent))])))))
|
||||
[path (url-path (path->url parent))]))))))
|
||||
|
||||
(define/public (go-cmd url-string)
|
||||
(if (non-empty-string? url-string)
|
||||
@@ -62,15 +66,19 @@
|
||||
(displayln (read-line document-buffer))
|
||||
(iter (sub1 depth)))))
|
||||
|
||||
(if (null? document-buffer)
|
||||
(displayln "you need to 'go' somewhere first!")
|
||||
(let ()
|
||||
(iter 10)
|
||||
(newline)
|
||||
(let ([remaining (pipe-content-length document-buffer)])
|
||||
(printf "~a bytes remaining\n" remaining)))
|
||||
(printf "~a bytes remaining\n" remaining)))))
|
||||
|
||||
(define/public (visit-cmd line)
|
||||
(define url (gmi:match-link document-object line))
|
||||
|
||||
(get (combine-url/relative current-url (url->string url))))
|
||||
(if (null? document-object)
|
||||
(displayln "you need to 'go' somewhere first!")
|
||||
(let ([url (gmi:match-link document-object line)])
|
||||
(get (combine-url/relative current-url (url->string url))))))
|
||||
|
||||
(define/private (get url)
|
||||
(define (iter url depth)
|
||||
@@ -93,6 +101,7 @@
|
||||
[(and (>= status 20)
|
||||
(<= status 29))
|
||||
|
||||
|
||||
(let-values ([(doc) (gmi:parse (port->lines c-in))]
|
||||
[(db-in db-out) (make-pipe #f)])
|
||||
|
||||
|
Reference in New Issue
Block a user