Env
Env module: environment variable access for application configuration.
Env.get/2 reads an env var, returning a default String if not set. Env.require/1 reads a required env var, panicking if absent. Env.get_int/2 and Env.get_bool/2 parse the raw string into typed values.
These are the primitives used in config/runtime.march files to build environment-specific configuration at application startup.
Usage: Env.get("PORT", "4000") -- "4000" (or env value) Env.require("SECRET_KEY_BASE") -- panics if not set Env.get_int("PORT", 4000) -- 4000 (parsed as Int) Env.get_bool("DEBUG", false) -- false (or true if "true"/"1"/"yes")
Functions
Read an environment variable, returning default if not set.
Examples
march> Env.get("MARCH_DOCTEST_NEVER_SET", "fallback")
"fallback"Read an environment variable and parse as Bool. Truthy values: "true", "1", "yes" (case-sensitive). All other values — including absent — fall back to default.
Examples
march> Env.get_bool("MARCH_DOCTEST_NEVER_SET", false)
false
march> Env.get_bool("MARCH_DOCTEST_NEVER_SET", true)
trueRead an environment variable and parse it as Int. Returns default if the variable is not set OR if it is set but not a valid integer (so callers can keep their typed default safely).
Examples
march> Env.get_int("MARCH_DOCTEST_NEVER_SET", 8080)
8080Return true if the variable is set to any value (including the empty string), false otherwise.
Examples
march> Env.is_set("MARCH_DOCTEST_NEVER_SET")
falseRead a required environment variable. Panics if not set, with the variable name in the message so the failure is self-diagnosing.
Examples
march> Env.require("MARCH_DOCTEST_NEVER_SET")
** panic: Env: required variable not set: MARCH_DOCTEST_NEVER_SETRead a required environment variable and parse it as Int. Panics if the variable is not set or its value does not parse as an integer (the message includes both the name and the offending value when the latter applies).
Examples
march> Env.require_int("MARCH_DOCTEST_NEVER_SET")
** panic: Env: required variable not set: MARCH_DOCTEST_NEVER_SET