Skip to content

Latest commit

 

History

History
46 lines (33 loc) · 1.18 KB

README.md

File metadata and controls

46 lines (33 loc) · 1.18 KB

scala-envconfig

Build status Apache 2.0 licensed

scala-envconfig is a simple Scala library for parsing configuration from environmental variables inspired by kelseyhightower/envconfig and joeshaw/envdecode libraries for Go.

Usage

import com.github.foxmk.envconfig._

@envprefix("FEATURE_")
case class Config(
  @env("NAME") name: String,
  @env("ENABLED", default = Some("true")) enabled: Boolean
)

Set up your enviroment:

export FEATURE_NAME=foo
export FEATURE_ENABLED=false

and parse the configuration:

import com.github.foxmk.envconfig._

val config = ConfigParser.parse[Config](sys.env) 

Known limitations

  • Config class should be top-level declaration
  • Parameters in env annotation should go in defined order (name and then default)