Skip to content

Latest commit

 

History

History
75 lines (47 loc) · 1.14 KB

env.md

File metadata and controls

75 lines (47 loc) · 1.14 KB

env

Environment and system. import env, effect.

env.unix_timestamp() -> Int

Get the current Unix timestamp in seconds.

let ts = env.unix_timestamp()

env.args() -> List[String]

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

let args = env.args()

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

Set an environment variable.

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

env.cwd() -> Result[String, String]

Get the current working directory.

let dir = env.cwd()

env.millis() -> Int

Get the current time in milliseconds since epoch.

let ms = env.millis()

env.sleep_ms(ms: Int) -> Unit

Sleep for the given number of milliseconds.

env.sleep_ms(1000) // sleep 1 second

env.temp_dir() -> String

Get the system temporary directory path.

let tmp = env.temp_dir()

env.os() -> String

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

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