-
Notifications
You must be signed in to change notification settings - Fork 1
/
hello.rkt
59 lines (53 loc) · 1.89 KB
/
hello.rkt
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#lang racket/base
(module+ test
(require rackunit))
;; Notice
;; To create an executable
;; $ raco exe -o hello hello.rkt
;;
;; see https://docs.racket-lang.org/raco/exe.html
;;
;; To share stand-alone executables:
;; $ raco distribute <directory> executable ...
;;
;; e.g
;; $ raco distribute greetings hello.exe
;;
;; creates a directory "greetings" (if the directory doesn’t exist already),
;; and it copies the executables "hello.exe" and "goodbye.exe" into "greetings".
;;
;; see https://docs.racket-lang.org/raco/exe-dist.html
;;
;; For your convenience, we have included LICENSE-MIT and LICENSE-APACHE files.
;; If you would prefer to use a different license, replace those files with the
;; desired license.
;;
;; Some users like to add a `private/` directory, place auxiliary files there,
;; and require them in `main.rkt`.
;;
;; See the current version of the racket style guide here:
;; http://docs.racket-lang.org/style/index.html
;; Code here
(require racket/cmdline racket/port)
(define who (box "world"))
(define (pipediput)
(for ([line (port->lines)])
(printf "hello ~a~n" line)))
(command-line
#:program "Greeter"
#:once-any
[("-n" "--name") name "Who to say hello to" (set-box! who name)]
[("-p" "--pipe") "greet piped list" (pipediput)]
#:args ()
(printf "hello ~a~n" (unbox who)))
(module+ test
;; Any code in this `test` submodule runs when this file is run using DrRacket
;; or with `raco test`. The code here does not run when this file is
;; required by another module.
(check-equal? (unbox who) "world"))
(module+ main
;; (Optional) main submodule. Put code here if you need it to be executed when
;; this file is run using DrRacket or the `racket` executable. The code here
;; does not run when this file is required by another module. Documentation:
;; http://docs.racket-lang.org/guide/Module_Syntax.html#%28part._main-and-test%29
(define who (box "world")))