REBOL 3.0

New command line usage

Carl Sassenrath, CTO
REBOL Technologies
9-Apr-2009 2:41 GMT

Article #0190
Main page || Index || Prior Article [0189] || Next Article [0191] || 1 Comments || Send feedback

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:

>> usage
Command line usage:

        REBOL <options> <script> <arguments>

All parts are optional.

Standard options:

        --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

Special options:

        --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

Examples:

        REBOL script.r
        REBOL -s script.r
        REBOL script.r 10:30 test@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.

System/options

The system options object holds all of the above fields that are provided on startup. The general mechanism is:

  1. If the command line flag is provided, it will appear in the system/option/flags block.
  2. If it has an associated value, that will be stored in the system/options object.

For example:

r3 --debug test example.r

You will see:

>> system/options/flags
[debug true]

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:

>> system/options/debug
[test]

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
>> system/options/debug
[net: on log: on]

So, that let's you do quite a lot.

1 Comments

REBOL 3.0
Updated 23-Dec-2024 - Edit - Copyright REBOL Technologies - REBOL.net