|
| 1 | +#lang racket/base |
| 2 | + |
| 3 | +(module+ test |
| 4 | + (require rackunit)) |
| 5 | + |
| 6 | +;; Notice |
| 7 | +;; To create an executable |
| 8 | +;; $ raco exe -o hello hello.rkt |
| 9 | +;; |
| 10 | +;; see https://docs.racket-lang.org/raco/exe.html |
| 11 | +;; |
| 12 | +;; To share stand-alone executables: |
| 13 | +;; $ raco distribute <directory> executable ... |
| 14 | +;; |
| 15 | +;; e.g |
| 16 | +;; $ raco distribute greetings hello.exe |
| 17 | +;; |
| 18 | +;; creates a directory "greetings" (if the directory doesn’t exist already), |
| 19 | +;; and it copies the executables "hello.exe" and "goodbye.exe" into "greetings". |
| 20 | +;; |
| 21 | +;; see https://docs.racket-lang.org/raco/exe-dist.html |
| 22 | +;; |
| 23 | +;; For your convenience, we have included LICENSE-MIT and LICENSE-APACHE files. |
| 24 | +;; If you would prefer to use a different license, replace those files with the |
| 25 | +;; desired license. |
| 26 | +;; |
| 27 | +;; Some users like to add a `private/` directory, place auxiliary files there, |
| 28 | +;; and require them in `main.rkt`. |
| 29 | +;; |
| 30 | +;; See the current version of the racket style guide here: |
| 31 | +;; http://docs.racket-lang.org/style/index.html |
| 32 | + |
| 33 | +;; Code here |
| 34 | +(require racket/cmdline) |
| 35 | +(define who (box "world")) |
| 36 | +(command-line |
| 37 | + #:program "my-program" |
| 38 | + #:once-each |
| 39 | + [("-n" "--name") name "Who to say hello to" (set-box! who name)] |
| 40 | + #:args () |
| 41 | + (printf "hello ~a~n" (unbox who))) |
| 42 | + |
| 43 | + |
| 44 | +(module+ test |
| 45 | + ;; Any code in this `test` submodule runs when this file is run using DrRacket |
| 46 | + ;; or with `raco test`. The code here does not run when this file is |
| 47 | + ;; required by another module. |
| 48 | + (check-equal? (unbox who) "world")) |
| 49 | + |
| 50 | +(module+ main |
| 51 | + ;; (Optional) main submodule. Put code here if you need it to be executed when |
| 52 | + ;; this file is run using DrRacket or the `racket` executable. The code here |
| 53 | + ;; does not run when this file is required by another module. Documentation: |
| 54 | + ;; http://docs.racket-lang.org/guide/Module_Syntax.html#%28part._main-and-test%29 |
| 55 | + (define who (box "world"))) |
0 commit comments