Scripting · CLI hosts
Run scripts & use the interactive shell.
The same native statement engine powers standalone files with nift run path and the persistent nift sh interpreter.
nift run
nift run scripts/report.nift who := read()
print("hello, $[who]")
return 0 A script starts in a fresh root scope. Fallthrough and bare return exit successfully without return output; return expression renders the returned value to stdout. Parse, runtime and I/O errors use stderr and a non-zero status.
nift sh
$ nift sh
~/project$ x := 10
~/project$ x++
~/project$ x
11
~/project$ ls().prettify()
[
"README.md",
"content",
"docs"
]
~/project$ cd("/tmp")
/tmp$ The shell retains one root lexical environment between commands. Bare expressions display their safe compact value directly, so inspecting x, ls() or another data expression does not require print(). Use .prettify() when an expanded human-readable representation is easier to inspect. Its prompt shows the current working directory followed by $. Paths below the user home directory are shortened from /home/<user>/... to ~/...; on a colour-capable terminal the path is bold green while $ remains in the terminal default colour. cd(path) changes both the process working directory and the next prompt. Use .highlight() on a serializable value to request syntax-coloured compact inspection in an interactive colour-capable REPL; the underlying returned string remains ANSI-free.
Ordinary errors are reported without destroying the persistent session. Multiline input uses the parser-reported statement state: an incomplete prefix (an unclosed block, parenthesis, bracket or quoted string) keeps the shell reading with a continuation prompt, while a complete statement executes and a balanced-but-invalid form is reported without terminating the session.