I am writing an application that uses command-line (from scheme/cmdline) to parse command line arguments. Consider the following simple test-app.ss program:<br><br>#lang scheme<br><br>(define verbose-mode (make-parameter #f))<br>
<br>(define input-file (make-parameter "input.xml"))<br><br>(define output-directory (make-parameter "output"))<br><br>(command-line<br> #:program "test-app"<br> #:once-each<br> [("-v" "--verbose") "Generate with verbose messages"<br>
(verbose-mode #t)]<br> [("-i" "--input-file") if<br> "Input file"<br> (input-file if)]<br> [("-o" "--output-directory") od<br>
"Output directory"<br> (output-directory od)]<br> #:args () (void))<br><br>(printf "Test Command-Line Application~n")<br>(printf " verbose-mode = ~a~n" (verbose-mode))<br>
(printf " input-file = ~s~n" (input-file))<br>(printf " output-directory = ~s~n" (output-directory))<br><br>When I make an executable of this using Scheme>Create Executable ... and select Stand-alone and MzScheme, I can get it to work, but I have some questions.<br>
<br>Why do I need "--" before my arguments? [They seem to be parsed by MzScheme if I don't.]<br><br>For example:<br><br>>test-app -v<br>Welcome to MzScheme v4.2 [3m], Copyright (c) 2004-2009 PLT Scheme Inc.<br>
Test Command-Line Application<br> verbose-mode = #f<br> input-file = "input.xml"<br> output-directory = "output"<br><br>I get the MzScheme banner and my application doesn't see the "-v". So presumable, MzScheme parsed it.<br>
<br>>test-app -- -v<br>Test Command-Line Application<br> verbose-mode = #t<br> input-file = "input.xml"<br> output-directory = "output"<br><br>Works as expected.<br><br>Is there any way to get this behavior without the "--"? Should I be using mzc to compile it instead of DrScheme?<br>
<br>It seems to work as expected if I select Launcher when using Scheme>Create Executable ....<br><br>What is the best way to test programs using command-line during development? It seems I'd like to be able to tell if I am NOT being executed from the command line and do some alternate processing in that case - either use the defaults or use current-command-line-arguments to set specific values and let command-line parse those.<br>
<br>Any help/thoughts would be welcome.<br><br>Thanks,<br>Doug<br>