glenvy/env
Strongly-typed access to environment variables.
Functions
pub fn get(
name: String,
parser parse: fn(String) -> Result(a, Nil),
) -> Result(a, Nil)
Returns the value for the environment variable with the given name.
Uses the provided parser
to parse the value.
Returns Error(Nil)
if the provided parser
returns Error(Nil)
.
pub fn get_bool(name: String) -> Result(Bool, Nil)
Returns the value for the environment variable with the given name as a Bool
.
The following values are parsed as True
:
true
t
yes
y
1
The following values are pased as False
:
false
f
no
n
0
The parsing is case-insensitive.
Returns Error(Nil)
if the environment variable cannot be parsed as a Bool
.
Use get
if you want to provide your own parser.
pub fn get_float(name: String) -> Result(Float, Nil)
Returns the value for the environment variable with the given name as a Float
.
Returns Error(Nil)
if the environment variable cannot be parsed as a Float
.
pub fn get_int(name: String) -> Result(Int, Nil)
Returns the value for the environment variable with the given name as an Int
.
Returns Error(Nil)
if the environment variable cannot be parsed as an Int
.
pub fn get_string(name: String) -> Result(String, Nil)
Returns the value for the environment variable with the given name as a String
.