summaryrefslogtreecommitdiff
path: root/ebus-racket/dumper.rkt
blob: adbc6fe3d810da7705ea8b286cf12eeba201ab35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#! /usr/bin/env racket
#lang racket

(require (prefix-in parser: "parser.rkt"))

;(define verbose? (make-parameter #f))
(define connect-host? (make-parameter null))
(define connect-port? (make-parameter null))

(define greeting
  (command-line
   #:once-each
;   [("-v") "Verbose mode" (verbose? #t)]
   [("-c" "--connect") host port
                       "Connect to server <host> <port>"
                       (connect-host? host)
                       (connect-port? (string->number port))
                       ]))
; Connect
(if (or (null? (connect-host?)) (null? (connect-port?)))
    (display "Using stdin")
    (let-values ([(cin cout) (tcp-connect (connect-host?) (connect-port?))])
      (display (format "Connected to ~s ~s ~n" (connect-host?) (connect-port?)))
      (current-input-port cin)))

;
(parser:read-ebus-loop (current-input-port))