One idea: you can put the argument-parsing code in the "main" submodule,
then tell DrRacket not to run the main submodule.
#lang racket
(define (run in-port)
"testing...")
(module+ main
(require racket/cmdline)
(command-line
#:args args
(run (if (null? args) (current-input-port) (open-input-file (car
args))))))
Then in DrRacket, click "Language -> Choose Language -> Show Details ->
Submodules to Run" and un-check "main".
On Wed, Feb 8, 2017 at 1:51 PM, Steve Byan's Lists <
[email protected]> wrote:
> I'm working on a script that I eventually plan to invoke from the command
> line. I'd like the script to either take a file name argument or, if no
> arguments, read from stdin. However, while developing the script in
> DrRacket, I'd like to not invoke the top-level function, and to instead
> define an input port on a test file for convenience when exercising the
> code from the DrRacket REPL.
>
> Is there a way for a module to distinguish between running in DrRacket and
> running from the racket or gracket command?
>
> Best regards,
> -Steve
>
> --
> Steve Byan
> [email protected]
> Littleton, MA
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.