pkg new: clarify 'module+ main' and 'module+ test' purpose

- edit the comments, thanks to John B Clements and Alex Gian and Alex McLin
  and Phil McGrath
- add simple example code
This commit is contained in:
Ben Greenman 2018-07-17 12:25:17 -04:00
parent eaaede9c2c
commit e97717ef2b

View File

@ -207,13 +207,29 @@ EOS
;; Code here
(module+ test
;; Tests to be run with raco 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? (+ 2 2) 4))
(module+ main
;; Main entry point, executed when run with the `racket` executable or DrRacket.
)
;; (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
(require racket/cmdline)
(define who (box "world"))
(command-line
#:program "my-program"
#:once-each
[("-n" "--name") name "Who to say hello to" (set-box! who name)]
#:args ()
(printf "hello ~a~n" (unbox who))))
EOS
)))