Skip to content

env

import env
FunctionSignatureDescription
unix_timestamp() -> IntGet the current Unix timestamp in seconds.
args() -> List[String]Get the command-line arguments as a list of strings.
get(String) -> Option[String]Get the value of an environment variable, or none if not set.
set(String, String) -> UnitSet an environment variable.
cwd() -> Result[String, String]Get the current working directory.
millis() -> IntGet the current time in milliseconds since epoch.
sleep_ms(Int) -> UnitSleep for the given number of milliseconds.
temp_dir() -> StringGet the system temporary directory path.
os() -> StringGet the operating system name (linux, macos, windows).

Get the current Unix timestamp in seconds.

let ts = env.unix_timestamp()

Get the command-line arguments as a list of strings.

let args = env.args()

Get the value of an environment variable, or none if not set.

env.get("HOME") // => some("/Users/alice")

env.set(name: String, value: String) -> Unit

Section titled “env.set(name: String, value: String) -> Unit”

Set an environment variable.

env.set("MY_VAR", "hello")

Get the current working directory.

let dir = env.cwd()

Get the current time in milliseconds since epoch.

let ms = env.millis()

Sleep for the given number of milliseconds.

env.sleep_ms(1000) // sleep 1 second

Get the system temporary directory path.

let tmp = env.temp_dir()

Get the operating system name (linux, macos, windows).

env.os() // => "macos"