Skip to content

dxworks/argumenthor

Repository files navigation

Argumenthor

A Kotlin library for parsing configuration values from multiple sources with type-safe field definitions.

Build Maven Central

Installation

Gradle (Kotlin DSL)

implementation("org.dxworks.utils:argumenthor:1.0.0")

Gradle (Groovy)

implementation 'org.dxworks.utils:argumenthor:1.0.0'

Maven

<dependency>
    <groupId>org.dxworks.utils</groupId>
    <artifactId>argumenthor</artifactId>
    <version>1.0.0</version>
</dependency>

Features

  • Multi-source configuration - Read values from command-line arguments, properties files, and environment variables
  • Type-safe fields - Generic field definitions with compile-time type safety
  • Priority-based fallback - Values are looked up across sources in configurable order
  • Pluggable architecture - Add custom sources by implementing ConfigurationSource

Usage

// Set up default sources (Args > Properties > Env)
ArgumenthorConfiguration.setDefaultSources()

// Register a field
val portField = NumberField("port")
ArgumenthorConfiguration.registerField(portField)

// Get value (checks all sources in priority order)
val port: Number? = Argumenthor.getValue("port")

// Or get from a specific source
val portFromEnv: Number? = Argumenthor.getValue("port", "env")

Configuration Sources

  • ArgsSource - Parses -argName=value format from command-line arguments
  • PropertiesSource - Loads values from Java properties files
  • EnvSource - Reads environment variables with optional prefix

Field Types

  • StringField - Basic strings
  • NumberField - Numeric values
  • StringListField - Comma-separated string lists
  • NumberListField - Comma-separated number lists

License

Apache License 2.0

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 3

  •  
  •  
  •  

Languages