Type-safe Kotlin configuration by delegates.
Supports the most common external configuration sources, including:
- Command line
- Environment Variables
- Properties, Yaml, and Spring-like profiles
.envfiles
Add 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 supportobject 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:
- From command line with
--port 443 - As an environment variable
PORT=80 - In a profile, like
application-dev.properties, addport=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.
