Environment

pub fn env_variables() -> vector<EnvVariable> env#read

Returns all environment variables as a vector of EnvVariable records (fields: name, value). Use to inspect or forward the full environment.

pub fn env_variable(name: text) -> text env#read

Returns the value of the environment variable name, or null when it is not set. A variable set to the empty string answers "", so == null tells the two apart. Use to read configuration from the shell environment.

pub fn arguments() -> vector<text> env#read

Functions for interacting with the host operating system. Returns the script-level arguments passed after the script path. Does not include the loft binary name or loft CLI flags.

pub fn ymd_days_ago(days: integer) -> text time#read

Returns the UTC calendar date days days before today as YYYY-MM-DD. Use for cutoff dates in time-window filters; negative days clamps to today.

pub fn directory(v: text = "") -> text env#read

Returns the current working directory, optionally with v appended as a subpath. loft sets the working directory to the program's own directory, so this is that directory — unless the file declares #cwd, which keeps the directory the program was launched from.

pub fn user_directory(v: text = "") -> text env#read

Returns the current user's home directory, optionally with v appended. Use for storing user-specific data or configuration.

pub fn program_directory(v: text = "") -> text env#read

Returns the directory containing the running executable, optionally with v appended. Use to locate assets shipped beside a compiled program. Under the interpreter the executable is the loft binary itself, and a --native run executes from a temporary build directory, so neither names the script's directory — use source_dir() for that.

pub fn source_dir() -> text env#read

Returns the directory containing the main source file being executed. Use to locate data files relative to the script, regardless of working directory.