项目作者: aPureBase

项目描述 :
Type-safe Kotlin configuration by delegates
高级语言: Kotlin
项目地址: git://github.com/aPureBase/arkenv.git
创建时间: 2018-10-11T14:29:52Z
项目社区:https://github.com/aPureBase/arkenv

开源协议:Apache License 2.0

下载


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:

  1. repositories { mavenCentral() }
  2. implementation "com.apurebase:arkenv:$arkenv_version"
  3. implementation "com.apurebase:arkenv-yaml:$arkenv_version" // for yaml support

🔨 Usage

1. Define your arguments with the argument delegate.

  1. object Arguments {
  2. val port: Int by argument()
  3. }

or use constructor injection:

  1. class Arguments(val port: Int)

2. Parse your arguments.

  1. fun main(args: Array<String>) {
  2. Arkenv.parse(Arguments, args) // object or existing instance
  3. Arkenv.parse<Arguments>(args) // constructor injection
  4. }

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.