Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aosasona/dotenv
Load environment variables from .env (or other) files in Gleam
https://github.com/aosasona/dotenv
Last synced: 27 days ago
JSON representation
Load environment variables from .env (or other) files in Gleam
- Host: GitHub
- URL: https://github.com/aosasona/dotenv
- Owner: aosasona
- Created: 2023-10-28T17:24:58.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-09-22T23:41:37.000Z (3 months ago)
- Last Synced: 2024-09-25T21:07:17.489Z (3 months ago)
- Language: Gleam
- Homepage: https://hexdocs.pm/dot_env
- Size: 85.9 KB
- Stars: 22
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-gleam - dot_env - [📚](https://hexdocs.pm/dot_env/) - Load environment variables from files (Packages / Configuration)
README
# dot_env
- [Quick start](#quick-start)
- [Installation](#installation)[![Package Version](https://img.shields.io/hexpm/v/dot_env)](https://hex.pm/packages/dot_env)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/dot_env/)dot_env is a port of the popular JavaScript [dotenv](https://github.com/motdotla/dotenv) package that helps you load environment variables from .env (or other) files.
> This package may support other formats in the future but for now, supports the popular .env format
>
> You can find the Javascript "tests" [here](https://github.com/aosasona/dot_js_test)## Quick start
```gleam
import dot_env as dot
import dot_env/env
import gleam/iopub fn main() {
dot.new()
|> dot.set_path("path/to/.env")
|> dot.set_debug(False)
|> dot.load// or dot_env.load_with_opts(dot_env.Opts(path: "path/to/.env", debug: False, capitalize: False))
// or `dot_env.load_default()` to load the `.env` file in the root pathcase env.get("MY_ENV_VAR") {
Ok(value) -> io.println(value)
Error(_) -> io.println("something went wrong")
}let app_name = env.get_or("APP_NAME", "my app name")
let port = env.get_int_or("PORT", 3000)
let enable_signup = env.get_bool_or("ENABLE_SIGNUP", True)io.debug(app_name)
io.debug(port)
io.debug(enable_signup)Nil
}
```## Installation
```sh
gleam add dot_env
```and its documentation can be found at .