Type-safe Kotlin configuration by delegates
Type-safe Kotlin configuration by
delegates.
Supports the most common external configuration sources, including:
.env
filesAdd Maven Central to your repositories and add Arkenv in Gradle:
repositories { mavenCentral() }
implementation "com.apurebase:arkenv:$arkenv_version"
implementation "com.apurebase:arkenv-yaml:$arkenv_version" // for yaml support
argument
delegate.
object Arguments {
val port: Int by argument()
}
or use constructor injection:
class Arguments(val port: Int)
fun main(args: Array<String>) {
Arkenv.parse(Arguments, args) // object or existing instance
Arkenv.parse<Arguments>(args) // constructor injection
}
You can specify additional custom names for each argument
.
The property’s name is used as a fallback.
By default, Arkenv supports parsing command line arguments,
environment variables, and profiles.
In the case of port
, you can parse it like this:
--port 443
PORT=80
application-dev.properties
, add port=5000
To get started, we recommend reading about the basics
for a quick tour of what’s included.
Please visit https://arkenv.io/ for in-depth documentation.
Find the Arkenv channel in the official Kotlin Slack.