Packages

An environment provider for fiction

Current section

Files

Jump to
fiction_env README.md
Raw

README.md

# fiction_env
[![Package Version](https://img.shields.io/hexpm/v/fiction_env)](https://hex.pm/packages/fiction_env)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/fiction_env/)
A provider for [fiction](https://hex.pm/packages/fiction) that processes environment variables.
```sh
gleam add fiction_env@1
```
```gleam
import fiction/providers/env
import fiction
pub fn main() -> Nil {
let assert Ok(_) =
fiction.new()
// collect all environment variables with a prefix,
// using the unprefixed and lowercased name as the key for the value (eg. APP_FOO -> foo)
|> fiction.join(env.prefixed("APP_"))
// try to get values from a list of names
// if a value is available the key will be the lowercased name (eg. FOO -> foo)
|> fiction.join(env.exact(["FOO", "BAR"]))
|> fiction.extract(..)
}
```
Further documentation can be found at <https://hexdocs.pm/fiction_env>.
## Development
```sh
gleam test # Run the tests
```