Run Bnlang Scripts from Command Line
Bnlang programs can be executed directly from the command line using the bnl
command.
This allows developers to quickly test, debug, and run scripts without extra setup.
Running a Script
# Run a script
bnl hello.bnl
Example Script
// file: hello.bnl
console.log("Hello, World!");
Running with Arguments
You can pass command-line arguments to Bnlang scripts using process.argv
.
// file: greet.bnl
const name = process.argv[2] || "Guest";
console.log("Hello,", name);
bnl greet.bnl Alice
# Output: Hello, Alice
Best Practices
- Keep scripts small and modular.
- Use meaningful file names.
- Validate input when using arguments.
- Organize scripts in a
scripts/
directory.