Skip to content
Jean-Luc Béchennec edited this page Nov 16, 2015 · 9 revisions

Command line options

-r, --root

By default, after having parsed an oil file, goil executes the root.goilTemplate template which is located in the templates directory. It is possible to specify another template file by using the --root option. The template file has to be located in the templates directory. This allows to perform custom computations on the abstract syntax tree of the oil file. The file must begin with the version of goil in the text part of the template.

example

Suppose for instance you want to count the number of tasks declared in an oil file. On the templates side, this information is the number of objects in the TASK list. So we could add a taskcount.goilTemplate file with the following content:

2.1.24% # goil version needed 
println [TASK length]

In this case, goil would be invoked with the --root=taskcount or -r=taskcount option.

-o, --option

This option can be use to pass a set of options to the templates. Passed options are a list of key=value separated by a ,. For instance let's suppose we want to pass options A and B with values 1 and 2. We would write -o='A=1,B=2'. key is any identifier matching the C naming rules. value may be

  • an identifier;
  • a string delimited by a pair of ";
  • a signed or unsigned integer number;
  • a floating point number;
  • a list of any of the above. A list starts with a ( and ends with a ). It contains values separated by ,.

Example

The following -o='ID=identifier, STR="a string", INT=1, SINT=-5, FLOAT=3.14159, SFLOAT=-10.5, LIST=(1,-1,2.7,-10,"hello world",maybe)' passes options ID with value "identifier", STR with value "a string", INT with value 1, SINT with value -5, FLOAT with value 3.14159, SFLOAT with value -10.5 and LIST with value (1,-1,2.7,-10,"hello world",maybe).

On the templates side, a PASSEDOPTIONS variable is available. This variable is a map/struct where the keys are the options. For instance, with the previous example, the PASSEDOPTIONS variable has the following content (printed with the display insruction) :

PASSEDOPTIONS (...) : struct
    FLOAT:
        3.14159
    ID:
        "identifier"
    INT:
        1
    LIST:
        item at 0:
            VALUE:
                1
        item at 1:
            VALUE:
                -1
        item at 2:
            VALUE:
                2.7
        item at 3:
            VALUE:
                -10
        item at 4:
            VALUE:
                "hello world"
        item at 5:
            VALUE:
                "maybe"
    SFLOAT:
        -10.5
    SINT:
        -5
    STR:
        "a string"

Clone this wiki locally