Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

DRSchlaubi/envconf

Repository files navigation

Project has moved to https://github.com/DRSchlaubi/stdx.kt

envconf

envconf is a small Kotlin MPP (currently JVM, JS) library, which helps you to use environment variables for your config

Example

// this gets the env variable "HELLO"
val HELLO by environment

// this gets the env variable "HELLO_COUNT" and converts it into an int
val HELLO_COUNT by getEnv { it.toInt() }

// this does the same as the one above
val COUNT by getEnv("HELLO_") { it.toInt() }

// this does the same as the one above, but it uses 1 if the variable is missing
val COUNT by getEnv("HELLO_", 1) { it.toInt() }

// this does the same as the one above, but it uses null if the variable is missing
val COUNT by getEnv("HELLO_", String::toInt).optional()

class Konfig : Config("HELLO_") {
    // this outsources the prefix to the constructor
    val COUNT by getEnv("HELLO_", 1) { it.toInt() }
}

Download

Gradle (Kotlin)
repositories {
    maven("https://schlaubi.jfrog.io/artifactory/envconf/")
}

dependencies {
    implementation("dev.schlaubi", "envconf", "1.1")
}
Gradle (Groovy)
repositories {
    maven { url "https://schlaubi.jfrog.io/artifactory/envconf/" }
}

dependencies {
    implementation 'dev.schlaubi:envconf:1.1'
}
Maven
<project>
  <repositories>
    <repository>
      <url>https://schlaubi.jfrog.io/artifactory/envconf/</url>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>dev.schlaubi</groupId>
      <artifactId>envconf-jvm</artifactId>
      <version>1.1</version>
    </dependency>
  </dependencies>
</project>

About

Kotlin library which makes it easy to use env variables for configs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages