New command line usage
R3-A47 handles the command line args much better. The host and core are processing them; however, we still have some work to do in intrinsic/begin to act on them.
To see what's now allowed:
Command line usage:
REBOL <options> <script> <arguments>
All parts are optional.
--args data Explicit arguments to script (quoted)
--do expr Evaluate expression (quoted)
--help (-?) Display this usage information
--import file Import a module prior to script
--script file Explicit script filename
--version tuple Script must be this version or greater
--cgi (-c) Load CGI utiliy module and modes
--debug flags Enable debug flags for script to use
--halt (-h) Leave console open when script is done
--quiet (-q) No startup banners or information
--secure policy Can be: none allow ask throw quit
--trace (-t) Enable trace mode during boot
--verbose Show detailed startup information
Other quick options:
-s No security
+s Full security
-v Display release version only
REBOL -s script.r
REBOL script.r 10:30 email@example.com
REBOL --do "watch: on" script.r
Notice that I left --cgi, even though it's not that important anymore (because in R3 it can be done in REBOL code). But, I think we can use that flag to load a CGI utilities module, which most CGI scripts need.
The new --debug flag is something I've wanted for a while. It's intended for your programs to check and act on as needed.
The --import function allows you to import another module before your program runs. It's the kind of thing you see in other languages, but we will need to see how useful it is for us. If not useful, we'll remove it.
The system options object holds all of the above fields that are provided on startup. The general mechanism is:
- If the command line flag is provided, it will appear in the system/option/flags block.
- If it has an associated value, that will be stored in the system/options object.
r3 --debug test example.r
You will see:
This method (placing TRUE at end) is used so you can write:
if system/options/flags/debug [...]
The test value provided on the command line will be found here:
That block is intended for use by your program/script, to enable your debug code in whatever way you want. It is not used by the system itself.
Note that the field must be valid REBOL source, or an error will occur.
You can also use string delimiters to pass multiple flags:
r3 --debug "net: on log: on" example.r
[net: on log: on]
So, that let's you do quite a lot.