CountBuilder

Builder for creating command-line count options with various configurations and constraints.

This class provides a fluent API for defining count options that track the number of times an option appears on the command line, including constraints and help text.

Functions

Link copied to clipboard

Requires at least n occurrences of this count option.

Link copied to clipboard
fun atLeastOneWith(vararg refs: KProperty<*>): CountBuilder

Ensures at least one of this count option and the specified properties is provided.

Link copied to clipboard
fun atMostOneWith(vararg refs: KProperty<*>): CountBuilder

Ensures at most one of this count option and the specified properties is provided.

Link copied to clipboard
fun conflictsWith(vararg refs: KProperty<*>): CountBuilder

Specifies that this count option conflicts with the specified properties.

Link copied to clipboard
fun exactlyOneWith(vararg refs: KProperty<*>): CountBuilder

Ensures exactly one of this count option and the specified properties is provided.

Link copied to clipboard

Sets help text for this count option.

Link copied to clipboard

Marks this count option as hidden from help output.

Link copied to clipboard
fun onlyInDomains(vararg refs: KProperty<*>): CountBuilder

Restricts this count option to be available only in the specified domains.

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

Provides the property delegate implementation for count options. This method is called automatically by Kotlin's property delegation system. It registers the count option with the Arguments instance and returns a delegate that provides access to the count value (number of times the option was specified).

Link copied to clipboard

Marks this count option as required, equivalent to atLeast(1).

Link copied to clipboard

Requires that this count option be present when all of the specified properties are present.

Link copied to clipboard

Requires that this count option be present along with any of the specified properties.

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

Requires that this count option be present when the specified property matches the given predicate.

Link copied to clipboard

Controls whether this count option requires a value.

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

Adds multiple validators at once.

fun validate(message: String = "Invalid count for @name: @value", predicate: (Int) -> Boolean): CountBuilder

Adds a validator that checks the count value against the given predicate.