https://github.com/coast-framework/env
Easy clojure environment variables
https://github.com/coast-framework/env
clojure environment environment-variables
Last synced: 6 months ago
JSON representation
Easy clojure environment variables
- Host: GitHub
- URL: https://github.com/coast-framework/env
- Owner: coast-framework
- License: mit
- Created: 2019-07-25T23:18:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-18T18:04:18.000Z (over 6 years ago)
- Last Synced: 2025-07-05T02:03:59.895Z (7 months ago)
- Topics: clojure, environment, environment-variables
- Language: Makefile
- Size: 9.77 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# env
Easy clojure environment variables
## Quickstart
Given an `.env` file in the root of your project directory:
```sh
A_VALUE=hello
```
```clojure
(ns your-project
(:require [env.core :as env]))
(env/env :a-value) ; => hello
```
## Install
Add this to your [deps.edn](https://clojure.org/guides/deps_and_cli)
```clojure
coast-framework/env {:mvn/version "1.0.3"}}
```
## Usage
Given a `.env` file above or the equivalent `env.edn`
### Conventions
Notice system environment variables and values in `.env` are all upper and snake case, while the `env.edn` variables are all lower, kebab case keywords.
```clojure
{:a-value "hello"}
```
This will return "hello"
```clojure
(env/env :a-value)
```
### Tagged literals
`env.edn` has one trick up it's sleeve, tagged literals. You can set a `#env` tagged literal to grab a value from the actual environment and commit `env.edn` *without* committing the secret to source control.
`env.edn` (committed to source control)
```clojure
{:a-secret-value #env :session-key}
```
`.env` (not committed to source control)
```sh
SESSION_KEY=123456
COAST_ENV=dev
```
```clojure
(env/env :a-secret-value) ; => "123456"
```
## Running the tests
```sh
cd env && make test
```