Home Documentation Templates Examples Showcase GitHub
Theme

Scripting · Console I/O

Console input & output.

print(value) writes one complete line to the process console. read() reads one line of interactive input under nift run and nift sh.

who := "Nift"
print("hello, $[who]")
print("hello, " + who)

Each print() invocation is a blocking atomic console write: Nift evaluates and renders the value first, then serializes the complete line so concurrent execution cannot interleave fragments of separate calls.

line := read()

if(line == null) {
    return
}

print("read: " + line)

read() removes the line terminator, returns null at EOF and reports an I/O failure as a runtime error. It is deliberately unavailable during ordinary website builds so a build cannot unexpectedly block waiting for stdin.