Skip to content

Latest commit

 

History

History
76 lines (52 loc) · 2.81 KB

README.md

File metadata and controls

76 lines (52 loc) · 2.81 KB

Maven Central Tests Pipelines Chat Awesome Kotlin Badge

Type-safe Kotlin configuration by delegates.

Supports the most common external configuration sources, including:

📦 Installation

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 support

🔨 Usage

1. Define your arguments with the argument delegate.

object Arguments {
    val port: Int by argument()
}

or use constructor injection:

class Arguments(val port: Int)

2. Parse your arguments.

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, add port=5000

To get started, we recommend reading about the basics for a quick tour of what's included.

📃 Documentation

Please visit https://arkenv.io/ for in-depth documentation.

🤝 Contributing PRs Welcome

Slack

Find the Arkenv channel in the official Kotlin Slack.