DomainBuilder

Builder for creating command-line domains (subcommands) with various configurations and constraints.

This class provides a fluent API for defining domains that can have their own sets of available options and domain-scoped constraints. Domains are useful for creating subcommands or modes in command-line applications.

Domains can be:

  • Regular domains: selectable from command line

  • Fragments: constraint templates that are never selectable but can be inherited by other domains

Functions

Link copied to clipboard
fun aliases(vararg names: String): DomainBuilder

Adds aliases for this domain.

Link copied to clipboard

Requires at least n values for the specified property when this domain is active.

Link copied to clipboard
fun atLeastOne(vararg refs: KProperty<*>): DomainBuilder

Ensures at least one of the specified properties is provided when this domain is active.

Link copied to clipboard
fun atMostOne(vararg refs: KProperty<*>): DomainBuilder

Ensures at most one of the specified properties is provided when this domain is active.

Link copied to clipboard
fun conflicts(vararg refs: KProperty<*>): DomainBuilder

Specifies that the specified properties conflict with each other when this domain is active.

Link copied to clipboard
fun exactlyOne(vararg refs: KProperty<*>): DomainBuilder

Ensures exactly one of the specified properties is provided when this domain is active.

Link copied to clipboard

Sets help text for this domain.

Link copied to clipboard
fun inherits(vararg domains: KProperty0<Boolean>): DomainBuilder

Inherits constraints from other domains or fragments.

Link copied to clipboard

Sets the display label for this domain.

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

Provides the property delegate implementation for domain options. This method is called automatically by Kotlin's property delegation system. It registers the domain with the Arguments instance and returns a delegate that indicates whether this domain is currently active/selected.

Link copied to clipboard

Requires the specified property to be present when this domain is active.

Link copied to clipboard
fun requireIfAllPresent(target: KProperty<*>, vararg refs: KProperty<*>): DomainBuilder

Requires the target property to be present when all of the specified properties are present and this domain is active.

Link copied to clipboard
fun requireIfAnyPresent(target: KProperty<*>, vararg refs: KProperty<*>): DomainBuilder

Requires the target property to be present when any of the specified properties are present and this domain is active.

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

Requires the target property to be present when the specified property matches the given predicate and this domain is active.