Skip to content

OptionBuilder<T>

extendsPropertyDelegateProvider<Arguments, ReadOnlyProperty<Arguments, T?>>

Builds a value-bearing option. The call you end with decides the property's type:

  • end here and the property is nullable, resolving to null when the option is absent;

  • required and default give a non-null value;

  • multiple collects repeats into a List<T>.

Refine the value type (.int(), .enum<E>(), .convert(...)) before choosing cardinality.

OptionBuilders.kt

Functions

boolean

fun boolean(): OptionBuilder<Boolean>

Parses the value as a Boolean: true/false, 1/0, yes/no, y/n, or on/off.

OptionBuilders.kt

convert

fun <R> convert(converter: Converter<R>): OptionBuilder<R>
OptionBuilders.kt

default

fun default(value: T): RequiredOptionBuilder<T>

Uses value when the option is absent.

OptionBuilders.kt

double

fun double(): OptionBuilder<Double>
OptionBuilders.kt

enum

inline fun <E> enum(): OptionBuilder<E>

Parses the value as the enum E, matching constant names case-insensitively.

OptionBuilders.kt

long

fun long(): OptionBuilder<Long>
OptionBuilders.kt

multiple

fun multiple(): OptionListBuilder<T>

Allows the option to repeat, collecting every occurrence into a List<T>.

OptionBuilders.kt

provideDelegate

open operator override fun provideDelegate(thisRef: Arguments, property: KProperty<*>): ReadOnlyProperty<Arguments, T?>
OptionBuilders.kt

required

fun required(): RequiredOptionBuilder<T>

Requires the option; parsing fails when it is absent.

OptionBuilders.kt

Released under the Apache License 2.0.