Skip to content

gcv/envvar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Envvar

A Clojure library designed to make working with environment variables easier. It borrows ideas from environ, but is friendlier for using non-checked-in user-specific .env files (similar to the Ruby dotenv gem), and allows simple dynamic augmentation of environment variable values. It does not support .lein-env integration.

Usage

Envvar resolves variable sources in the following order (lower numbers have priority, so dynamic overrides have highest priority):

  1. Dynamic overrides.
  2. Anything in user-loaded Java properties files.
  3. Values in the .env file in the project (a Java properties file).
  4. Java system properties.
  5. Environment variables.
(require '[envvar.core :as envvar :refer [env with-env]])

;; return all environment variables as a map:
@env

;; return the value of the PATH environment variable:
(:path @env)

;; augment the environment:
(with-env [:one "hello", :two "world"]
  ;; @env will now also contain dynamically-scoped bindings for :one and :two
)

;; load more properties into the environment
(envvar/load-file-variables! "/path/to/properties.file")

;; reset all loaded properties, including ones from the .env file
(envvar/reset-file-variables!)

Leiningen

[envvar "1.1.2"]

Maven

<dependency>
  <groupId>envvar</groupId>
  <artifactId>envvar</artifactId>
  <version>1.1.2</version>
</dependency>

License

Distributed under the Eclipse Public License version 2.0.

About

Clojure library for handling environment variables

Resources

License

Stars

Watchers

Forks

Packages

No packages published