Command Line Tools - netrium/Netrium GitHub Wiki
Whilst the Netrium Contract Engineer is the most productive mechanism to develop and simulate contracts, there are times when a command line tool may be more appropriate for a particular development workflow.
Netrium offers three command line tools, all of which are cross platform and have been extensively tested on Linux, Microsoft Windows and OS X.
See also Using the Command Line Tools
All the command line tools either produce or consume the Intermediate Contract Format. This XML based representation of a contract is the basis for executing the contract and can be cross compiled into other technologies, such as C. Once in the Intermediate Contract Format, the Contract is no longer in a Haskell form.
The Netrium Compiler (known as normalise
) is used to compile the Haskell code and produce the output Intermediate Contract Format. It accepts the original Haskell source file, plus an optional list of additional modules (for example, Netrium includes a core library as well as an extended Option library).
As with most compilers, the tool provides stdout and stderr access to compiler errors, which can easily be integrated into Continuous Build environments.
Usage: normalise [options] <input> [<output.xml>]
Option | Use |
---|---|
--obs-db=obsdb.xml | Specifies the Observable database (obsdb.xml) |
--units-db=unitsdb.xml | Specifies the Units database (unitsdb.xml) |
--import-dir=DIR | Specifies the folder to reference for modules referenced in the `import` statements |
--fast | Outputs Intermediate Contract Language without any whitespace or pretty print formatting. Can reduce file size dramatically. |
--version | Outputs the version information |
The Netrium Simulator (known as simulate
) is used to execute a contract. It accepts Intermediate Contract Format, as well as time series data sets and a set of parameters defining how to execute the contract (at what time, until what time etc). The output is by default XML, and may include a residual contract in Intermediate Contract Format should the contract not have completed execution due to being stopped due to missing observable data or being artificially stopped by the runtime options.
Usage: simulate <contract.xml> <observations.xml> [<output.xml>]
Option | Use |
---|---|
--xml | Output in the standard XML based Intermediate Contract Format (default) |
--text | Output in a readable text format |
--trace | Outputs a trace of contract steps (useful for debugging). |
--tests | Run internal tests to validate simulate behavior |
--version | Outputs the version information |
The Visualiser (known as visualise
) is a tool used to create Visualisations of a contract that has a Intermediate Contract Format representation. These visualisations are of two types: a syntax tree, which describes the contract’s structure visually as well as decision tree, which gives a view on how the Netrium runtime will execute the contract. These visualised contracts can be saved in PNG, GraphViz Dot and SVG formats.
Note: Visualise requires GraphViz to be installed.
Usage: visualise <contract.xml> [<output>]
Option | Use |
---|---|
--syntax-tree | Outputs the Syntax Tree |
--decision-tree | Outputs the contract Decision Tree. |
--start-time=TIME | Required for Decision Tree mode. This is the time at which the contract is acquired. For example: --start-time="2018-05-01 23:59:59" |
--tree-depth=NUM | Limits the tree depth to a fixed amount. Default is 8. |
--svg | Outputs a SVG file |
--png | Outputs a PNG file. Depending on the operating system, the size of PNG may be constrained by the GraphViz runtime. SVG is recommended for all complex contracts. |
--dot | Outputs a GraphViz dot file. |
--version | Outputs the version information |