Module
pooka/env
src/pooka/env.pookaThe process arrives with a little weather from its surroundings.
Read arguments, environment variables and platform information through Erlang. Missing variables use Option, while operating-system failures use EnvError. Arguments exclude the Pooka executable entrypoint.
import pooka/env
let assert Ok(value) = env.get("POOKA_EXAMPLE")
API reference
class EnvError(message: String)
A env failure carrying the details needed by its caller. Keep this value in Result until a boundary can explain it.
message: String
String
fn(String) -> pooka/env.EnvErrorargs() -> List(String)
fn() -> List(String)Return program arguments without the executable entrypoint path.
import pooka/env
let arguments = env.args()
get(name: String) -> Result(Option(String), EnvError)
fn(String) -> Result(Option(String), pooka/env.EnvError)Read a variable. An absent name returns Ok(None).
import pooka/env
let assert Ok(value) = env.get("POOKA_EXAMPLE")
set(name: String, value: String) -> Result(Nil, EnvError)
fn(String, String) -> Result(Nil, pooka/env.EnvError)Set a variable in this process environment.
import pooka/env
let result = env.set("POOKA_EXAMPLE", "oak")
unset(name: String) -> Result(Nil, EnvError)
fn(String) -> Result(Nil, pooka/env.EnvError)Remove a variable from this process environment.
import pooka/env
let result = env.unset("POOKA_EXAMPLE")
current_directory() -> Result(String, EnvError)
fn() -> Result(String, pooka/env.EnvError)Read the current working directory, retaining operating-system failure as EnvError.
import pooka/env
let result = env.current_directory()
home_directory() -> Result(Option(String), EnvError)
fn() -> Result(Option(String), pooka/env.EnvError)Read the home directory when available.
import pooka/env
let result = env.home_directory()
os() -> String
fn() -> StringReturn the Erlang runtime's operating-system name.
import pooka/env
let system = env.os()
architecture() -> String
fn() -> StringReturn the runtime system architecture string.
import pooka/env
let architecture = env.architecture()