sys module

Process-level information: command-line arguments, environment variables, current directory, and a way to exit with a status code.

import "sys" as sys;

print("argv count:", sys.argc());
print("user:",       sys.env("USER"));
print("cwd:",        sys.cwd());

API

FunctionDescription
sys.argc() → numberCount of arguments passed to the script (not counting bnl itself or the script path).
sys.arg(i) → stringThe i-th argument (0-indexed). Throws on out-of-range.
sys.env(name) → string | nullLook up one environment variable.
sys.envs() → mapSnapshot of every environment variable as a {KEY: value} map.
sys.cwd() → stringThe process's current working directory.
sys.exit(code)Exit the process with the given status code.
sys.platform"windows", "linux", or "macos".

See also

  • cli — declarative CLI argument parsing on top of sys.argc/sys.arg.
  • dotenv — read .env files into env-style maps.