Packaged Utilities

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

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

rhai-repl – The Rhai REPL Tool

rhai-repl is a particularly useful utility program – 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 Utility Program

Utilities can be run with the following command:

cargo run --bin {program_name}