CLI Reference — `scrii_repl`
CLI Reference — scrii_repl
The interpreter ships as a single binary, scrii_repl, built via the super-build:
cmake --build build --target scrii_repl
# -> build/interpreter/scrii_repl
Synopsis
scrii_repl # start interactive REPL
scrii_repl <script file> [args] # run a script file and exit
With a file argument the engine calls exec_file(path) — relative import() paths resolve against that file’s directory. Errors print as STATUS: message and the process exits 1 on failure, 0 on success.
Scripts are directly executable: a leading #! line is just a # comment, so chmod +x plus a shebang works:
printf '#!/usr/bin/env scrii_repl\nprint("hi")\n' > hi.scr
chmod +x hi.scr
./hi.scr # hi
Arguments after the script file (./hi.scr a b, scrii_repl prog.scr a b, or scrii_repl -e '...' a b) reach the script as std.env.args() — ["a", "b"] (program and script names excluded; -- stops option parsing as usual).
Without arguments the process enters the interactive loop.
REPL behavior
- Multi-line buffering — input is collected until braces/parens/brackets are balanced and strings are closed; the prompt switches from
>to...while the buffer is incomplete. Only then is the buffer handed toengine.exec(buffer). - Persistence — variables declared with
var/constpersist across prompts in the same engine. Restart the process for a fresh engine. - History — last 25 non-empty lines, navigable with Up/Down arrows. Duplicate consecutive entries are not stored twice.
- Editing — Emacs-style keys:
Ctrl-A(BOL),Ctrl-E(EOL),Ctrl-K(kill to EOL),Ctrl-U(kill to BOL),Ctrl-D/ EOF to exit,Tabinserts 4 spaces, Backspace/Delete work.
Interactive commands
| Command | Effect |
|---|---|
:quit, :exit |
Leave the interpreter |
:clear |
Discard the current incomplete buffer and reset nesting state |
:help |
Print REPL help plus help() hint |
help() (inside script) |
List every builtin as name - description; help(std) / help(std.string) drills into modules (see Builtins) |
Ctrl-D |
EOF — same as :quit |
> var x = 40 + 2
> print(x)
42
> :help
commands:
:quit, :exit leave the interpreter
:clear discard the current (possibly incomplete) script
:help show this text
type help() for a list of built-in functions and their descriptions
...
Exit codes
| Code | Meaning |
|---|---|
0 |
Script ran cleanly (or REPL exited normally) |
1 |
exec_file failed — status printed to stderr |
Use std.exit(code) inside a script to terminate with a custom code (see std.os).
See also
- Getting Started — building and first program
- Examples — runnable
examples/*.scrinvoked via this CLI - Embedding —
exec/exec_file/submitfrom C++ (same engine, no CLI)