scala-envconfig
is a simple Scala library for parsing configuration
from environmental variables inspired by
kelseyhightower/envconfig
and joeshaw/envdecode libraries for Go.
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)
- Config class should be top-level declaration
- Parameters in
env
annotation should go in defined order (name
and thendefault
)