Run Bnlang Scripts from Command Line
The bnl CLI is the single entry point to the runtime. It can run a script file, evaluate inline code with -e, or drop into a REPL when called with no arguments.
Running a Script File
# Run a script
bnl hello.bnl
// file: hello.bnl
print("Hello, World!");
Inline Code with -e
bnl -e 'print(1 + 2);'
# 3
Starting the REPL
Running bnl with no arguments opens an interactive prompt. Useful for poking at the language or trying out stdlib calls.
bnl
> print("hi");
hi
> 1 + 2
3
Passing Arguments
Anything after the script path (or after the -e code) is forwarded to the script. Read them with sys.arg(i) / sys.argc().
// file: greet.bnl
import "sys" as sys;
var name = "Guest";
if (sys.argc() > 0) {
name = sys.arg(0);
}
print("Hello,", name);
bnl greet.bnl Alice
# Output: Hello, Alice
Best Practices
- Keep scripts small and focused — one entry point per file.
- For anything past a handful of arguments, switch from
sys.argto theclimodule for proper flag parsing. - Use
bnl --versionin CI logs so you know which interpreter built which output.