Skip to content

Commit b8c8006

Browse files
committed
added commands
1 parent dde66eb commit b8c8006

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

hello.rkt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@
3131
;; http://docs.racket-lang.org/style/index.html
3232

3333
;; Code here
34-
(require racket/cmdline)
34+
(require racket/cmdline racket/port)
3535
(define who (box "world"))
36+
(define (pipediput)
37+
(for ([line (port->lines)])
38+
(printf "hello ~a~n" line)))
3639
(command-line
37-
#:program "my-program"
38-
#:once-each
40+
#:program "Greeter"
41+
#:once-any
3942
[("-n" "--name") name "Who to say hello to" (set-box! who name)]
43+
[("-p" "--pipe") "greet piped list" (pipediput)]
4044
#:args ()
4145
(printf "hello ~a~n" (unbox who)))
4246

names.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Orlando
2+
Jack
3+
Sorawee
4+
Laurent
5+
Jens

test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cat names.txt | ./hello -p
2+
./hello -n Sam

0 commit comments

Comments
 (0)