Standard Library

std.env

Environment variable access and working directory management.

Exported functions

pub def get(name: String) -> String

Get the value of an environment variable.

pub def get_or(name: String, fallback: String) -> String

Get the value of an environment variable, or a fallback when it is unset.

pub def has(name: String) -> Bool

Return true when an environment variable is set.

pub def require(name: String) -> String

Get an environment variable or fail when it is unset.

pub def set(name: String, value: String) -> Void

Set an environment variable.

pub def unset(name: String) -> Void

Unset an environment variable.

pub def vars() -> Dict[String, String]

Get all environment variables as a dictionary.

pub def cwd() -> String

Get the current working directory.

pub def set_cwd(path: String) -> Void

Change the current working directory.

pub def temp_dir() -> String

Return the platform temporary directory.

pub def home_dir() -> String

Return the user home directory when available.

pub def config_dir() -> String

Return the user configuration directory when available.