env
import envFunctions
Section titled “Functions”| Function | Signature | Description |
|---|---|---|
unix_timestamp | () -> Int | Get 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) -> Unit | Set an environment variable. |
cwd | () -> Result[String, String] | Get the current working directory. |
millis | () -> Int | Get the current time in milliseconds since epoch. |
sleep_ms | (Int) -> Unit | Sleep for the given number of milliseconds. |
temp_dir | () -> String | Get the system temporary directory path. |
os | () -> String | Get the operating system name (linux, macos, windows). |
Reference
Section titled “Reference”env.unix_timestamp() -> Int
Section titled “env.unix_timestamp() -> Int”Get the current Unix timestamp in seconds.
let ts = env.unix_timestamp()env.args() -> List[String]
Section titled “env.args() -> List[String]”Get the command-line arguments as a list of strings.
let args = env.args()env.get(name: String) -> Option[String]
Section titled “env.get(name: String) -> Option[String]”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")env.cwd() -> Result[String, String]
Section titled “env.cwd() -> Result[String, String]”Get the current working directory.
let dir = env.cwd()env.millis() -> Int
Section titled “env.millis() -> Int”Get the current time in milliseconds since epoch.
let ms = env.millis()env.sleep_ms(ms: Int) -> Unit
Section titled “env.sleep_ms(ms: Int) -> Unit”Sleep for the given number of milliseconds.
env.sleep_ms(1000) // sleep 1 secondenv.temp_dir() -> String
Section titled “env.temp_dir() -> String”Get the system temporary directory path.
let tmp = env.temp_dir()env.os() -> String
Section titled “env.os() -> String”Get the operating system name (linux, macos, windows).
env.os() // => "macos"