NonNullableOptionBuilder

Builder for non-nullable command-line options. This type is returned by .default() and .required() to ensure type safety. It delegates most operations to the underlying OptionBuilder while ensuring type safety.

Constructors

Link copied to clipboard
constructor(delegate: OptionBuilder<T?>)

Properties

Link copied to clipboard

Functions

Link copied to clipboard

Creates an "at least one" constraint with other options. At least one option from this group (including this option) must be provided.

Link copied to clipboard

Creates an "at most one" constraint with other options. At most one option from this group (including this option) may be provided.

Link copied to clipboard

Specifies that this option conflicts with other options. If this option is provided along with any of the conflicting options, parsing will fail with an error.

Link copied to clipboard

Converts non-nullable string option to non-nullable double option.

Link copied to clipboard
inline fun <E : Enum<E>> NonNullableOptionBuilder<String>.enum(aliases: Map<String, E> = emptyMap(), ignoreCase: Boolean = true): NonNullableOptionBuilder<E>

Converts non-nullable string option to non-nullable enum option.

Link copied to clipboard

Creates an "exactly one" constraint with other options. Exactly one option from this group (including this option) must be provided.

Link copied to clipboard

Converts non-nullable string option to non-nullable float option.

Link copied to clipboard

Configures this option to read its value from an environment variable. If the command-line option is not provided, the specified environment variable will be checked for a value.

Link copied to clipboard

Sets the help text for this option. The help text is displayed when the user requests help information.

Link copied to clipboard

Marks this option as hidden from help output. Hidden options are not displayed in help text but remain functional.

Link copied to clipboard

Converts non-nullable string option to non-nullable integer option.

Link copied to clipboard

Converts non-nullable string option to non-nullable long option.

Link copied to clipboard
fun <R : Any> map(desc: String? = null, f: (T) -> R?): OptionBuilder<R?>

Maps the parsed value, allowing nullable output.

fun <R : Any> map(desc: String? = null, f: (T) -> R): NonNullableOptionBuilder<R>

Maps the parsed value using the specified transformation function. Preserves non-nullable type when transformation returns non-null.

Link copied to clipboard

Makes a non-nullable boolean option negatable with custom prefix.

Link copied to clipboard

Restricts non-nullable string option to one of the specified allowed values.

Link copied to clipboard

Restricts this option to only be available in specific domains. When specified, this option will only be recognized when one of the referenced domains is active.

Link copied to clipboard
fun onValue(callback: (T) -> Unit): NonNullableOptionBuilder<T>

Registers a callback to be executed when this option's value is found during parsing. The callback receives the converted non-null value and is executed after all parsing and validation completes.

Link copied to clipboard
open operator override fun provideDelegate(thisRef: Arguments, property: KProperty<*>): ReadOnlyProperty<Arguments, T>

Provides the property delegate implementation for non-nullable options. This method is called automatically by Kotlin's property delegation system. It delegates to the underlying OptionBuilder but ensures the returned value is non-null.

Link copied to clipboard

Makes this option required if all of the referenced options are present. This creates a conditional requirement where providing all of the trigger options makes this option mandatory.

Link copied to clipboard

Makes this option required if any of the referenced options are present. This creates a conditional requirement where providing any of the trigger options makes this option mandatory.

Link copied to clipboard
fun <U> requireIfValue(ref: KProperty<U>, predicate: (U?) -> Boolean): NonNullableOptionBuilder<T>

Makes this option required if the referenced option's value matches the predicate. This creates a value-based conditional requirement.

Link copied to clipboard
fun validate(vararg validations: Pair<String, (T) -> Boolean>): NonNullableOptionBuilder<T>

Adds multiple validations for this option's value. All validations are applied to the parsed non-null value.

fun validate(message: String = "Invalid value for @name: @value", predicate: (T) -> Boolean): NonNullableOptionBuilder<T>

Adds validation for this option's value. The validation is applied to the parsed non-null value.