CLI Reference — scrii

The interpreter ships as a single binary built via the super-build. The
interpreter’s CMake target is scrii_repl; the produced binary is
build/interpreter/scrii:

cmake --build build --target scrii_repl
# -> build/interpreter/scrii

Synopsis

scrii                             # start interactive REPL
scrii [options] <script> [args]   # run a script and exit
scrii -e <code> [args]            # run inline code and exit

options:
  -h, --help      show this text and exit
  -v, --version   print the engine version and exit
  --echo          echo values that root-level statements discard
  --              stop option parsing

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\nprint("hi")\n' > hi.scr
chmod +x hi.scr
./hi.scr   # hi

Arguments after the script file (./hi.scr a b, scrii prog.scr a b, or scrii -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 to engine.exec(buffer).
  • Persistence — variables declared with var/const persist across prompts in the same engine. Restart the process for a fresh engine.
  • Echo — interactive sessions echo the value of root-level statements that would otherwise be discarded: 1 + 2 on its own line prints 3. Nil results, assignments, pipe self-assignments, and anything inside blocks, loop bodies, function bodies, or imported modules never echo. Piped input (echo '1 + 2' | scrii) and script files stay silent unless --echo is passed; :echo toggles it at the prompt. Echo output goes through the current print — same destination, same rendering.
  • 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, Tab inserts 4 spaces, Backspace/Delete work.

Interactive commands

Command Effect
:quit, :exit Leave the interpreter
:clear Discard the current incomplete buffer and reset nesting state
:echo Toggle echo of discarded root-level values (on by default in interactive sessions)
: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
  :echo          toggle echo of discarded root-level values
  :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/*.scr invoked via this CLI
  • Embedding — exec/exec_file/submit from C++ (same engine, no CLI)