Packaged Utilities

A number of Rhai-driven tools can be found in the src/bin directory:

ToolDescription
rhai-repla simple REPL, interactively evaluate statements from stdin
rhai-runruns each filename passed to it as a Rhai script

Install Tools

To install these tools, use the following command:

cargo install --path . --bins

or specifically:

cargo install --path . --bin rhai-run

rhai-repl – The Rhai REPL Tool

rhai-repl is a particularly useful tool – it allows one to interactively try out Rhai’s language features in a standard REPL (Read-Eval-Print Loop).

Filenames passed to it as command line arguments are run and loaded before the REPL starts.

Example

The following command first runs three scripts – init1.rhai, init2.rhai and init3.rhai – loading the functions defined in each script into the global namespace.

Then it enters an REPL, which can call the above functions freely.

rhai-repl init1.rhai init2.rhai init3.rhai

rhai-run – The Rhai Runner

Use rhai-run to run Rhai scripts.

Filenames passed to it as command line arguments are run in sequence.

Example

The following command runs the scripts script1.rhai, script2.rhai and script3.rhai in order.

rhai-run script1.rhai script2.rhai script3.rhai

Running a Tool from Cargo

Tools can also be run with the following cargo command:

cargo run --bin {program_name}