OptionWithValues

class OptionWithValues<AllT, EachT, ValueT> : OptionDelegate<AllT> , GroupableOption

An Option that takes one or more values.

Functions

Link copied to clipboard
fun copy(validator: OptionValidator<AllT> = this.transformValidator, names: Set<String> = this.names, metavarWithDefault: ValueWithDefault<Context.() -> String?> = this.metavarWithDefault, nvalues: Int = this.nvalues, help: String = this.optionHelp, hidden: Boolean = this.hidden, helpTags: Map<String, String> = this.helpTags, envvar: String? = this.envvar, valueSourceKey: String? = this.valueSourceKey, valueSplit: <ERROR CLASS>? = this.valueSplit, parser: OptionWithValuesParser = this.parser, completionCandidatesWithDefault: ValueWithDefault<CompletionCandidates> = this.completionCandidatesWithDefault): OptionWithValues<AllT, EachT, ValueT>

Create a new option that is a copy of this one with the same transforms.

fun <AllT, EachT, ValueT> copy(transformValue: ValueTransformer<ValueT>, transformEach: ArgsTransformer<ValueT, EachT>, transformAll: CallsTransformer<EachT, AllT>, validator: OptionValidator<AllT>, names: Set<String> = this.names, metavarWithDefault: ValueWithDefault<Context.() -> String?> = this.metavarWithDefault, nvalues: Int = this.nvalues, help: String = this.optionHelp, hidden: Boolean = this.hidden, helpTags: Map<String, String> = this.helpTags, valueSourceKey: String? = this.valueSourceKey, envvar: String? = this.envvar, valueSplit: <ERROR CLASS>? = this.valueSplit, parser: OptionWithValuesParser = this.parser, completionCandidatesWithDefault: ValueWithDefault<CompletionCandidates> = this.completionCandidatesWithDefault): OptionWithValues<AllT, EachT, ValueT>

Create a new option that is a copy of this one with different transforms.

Link copied to clipboard
open override fun finalize(context: Context, invocations: List<OptionParser.Invocation>)

Called after this command's argv is parsed to transform and store the option's value.

Link copied to clipboard
open fun getValue(thisRef: ParameterHolder, property: KProperty<*>): AllT
Link copied to clipboard
open override fun metavar(context: Context): String?

A name representing the values for this option that can be displayed to the user.

Link copied to clipboard
open fun parameterHelp(context: Context): HelpFormatter.ParameterHelp.Option?

Information about this option for the help output.

Link copied to clipboard
open override fun postValidate(context: Context)

Called after all of a command's parameters have been finalized to perform validation of the final value.

Link copied to clipboard
open operator override fun provideDelegate(thisRef: ParameterHolder, prop: KProperty<*>): <ERROR CLASS><ParameterHolder, AllT>

Implementations must call ParameterHolder.registerOption

Properties

Link copied to clipboard
open override val completionCandidates: CompletionCandidates

Optional set of strings to use when the user invokes shell autocomplete on a value for this option.

Link copied to clipboard
Link copied to clipboard
val envvar: String?

The environment variable name to use.

Link copied to clipboard
open override var groupName: String? = null

The name of the group, or null if this option should not be grouped in the help output.

Link copied to clipboard
open override val helpTags: Map<String, String>

Extra information about this option to pass to the help formatter.

Link copied to clipboard
open override val hidden: Boolean

If true, this option should not appear in help output.

Link copied to clipboard
val metavarWithDefault: ValueWithDefault<Context.() -> String?>

The metavar to use. Specified at option creation.

Link copied to clipboard
open override var names: Set<String>

The names that can be used to invoke this option. They must start with a punctuation character.

Link copied to clipboard
open override val nvalues: Int

The number of values that must be given to this option.

Link copied to clipboard
open override val optionHelp: String

The description of this option, usually a single line.

Link copied to clipboard
open override var parameterGroup: ParameterGroup? = null

The group that this option belongs to, or null. Set by the group.

Link copied to clipboard
open override val parser: OptionWithValuesParser

The parser for this option's values.

Link copied to clipboard
open override val secondaryNames: Set<String>

Names that can be used for a secondary purpose, like disabling flag options.

Link copied to clipboard
val transformAll: CallsTransformer<EachT, AllT>

Called in finalize to transform all invocations into the final value.

Link copied to clipboard
val transformEach: ArgsTransformer<ValueT, EachT>

Called in finalize to transform each invocation.

Link copied to clipboard
val transformValidator: OptionValidator<AllT>

Called after all parameters have been finalized to validate the output of transformAll

Link copied to clipboard
val transformValue: ValueTransformer<ValueT>

Called in finalize to transform each value provided to each invocation.

Link copied to clipboard
open override var value: AllT

The value for this option.

Link copied to clipboard
open override val valueSourceKey: String?

Optional explicit key to use when looking this option up from a ValueSource

Link copied to clipboard
val valueSplit: <ERROR CLASS>?

The pattern to split values from the command line on. By default, values are split on whitespace.

Extensions

Link copied to clipboard
inline fun <AllT : Any, EachT, ValueT> OptionWithValues<AllT, EachT, ValueT>.check(message: String, crossinline validator: (AllT) -> Boolean): OptionDelegate<AllT>
inline fun <AllT : Any, EachT, ValueT> OptionWithValues<AllT?, EachT, ValueT>.check(message: String, crossinline validator: (AllT) -> Boolean): OptionDelegate<AllT?>

Check the final option value and raise an error if it's not valid.

inline fun <AllT : Any, EachT, ValueT> OptionWithValues<AllT, EachT, ValueT>.check(crossinline lazyMessage: (AllT) -> String = { it.toString() }, crossinline validator: (AllT) -> Boolean): OptionDelegate<AllT>
inline fun <AllT : Any, EachT, ValueT> OptionWithValues<AllT?, EachT, ValueT>.check(crossinline lazyMessage: (AllT) -> String = { it.toString() }, crossinline validator: (AllT) -> Boolean): OptionDelegate<AllT?>

Check the final argument value and raise an error if it's not valid.

Link copied to clipboard
fun <AllT, EachT, ValueT> OptionWithValues<AllT, EachT, ValueT>.deprecated(message: String? = "", tagName: String? = "deprecated", tagValue: String = "", error: Boolean = false): OptionDelegate<AllT>

Mark this option as deprecated in the help output.

Link copied to clipboard
fun <AllT, EachT, ValueT> OptionWithValues<AllT, EachT, ValueT>.help(help: String): OptionWithValues<AllT, EachT, ValueT>

Set the help for this option.

Link copied to clipboard
fun <T : Comparable<T>> OptionWithValues<T?, T, T>.restrictTo(min: T? = null, max: T? = null, clamp: Boolean = false): OptionWithValues<T?, T, T>
fun <T : Comparable<T>> OptionWithValues<T?, T, T>.restrictTo(range: ClosedRange<T>, clamp: Boolean = false): OptionWithValues<T?, T, T>

Restrict the option values to fit into a range.

Link copied to clipboard
fun <A, B, EachT, ValueT> OptionWithValues<List<<ERROR CLASS><A, B>>, EachT, ValueT>.toMap(): OptionWithValues<Map<A, B>, EachT, ValueT>

Convert this option's values from a list of pairs into a map with key-value pairs from the list.

Link copied to clipboard
fun <T, EachT, ValueT> OptionWithValues<List<T>, EachT, ValueT>.unique(): OptionWithValues<Set<T>, EachT, ValueT>

Make a multiple option return a unique set of values

Link copied to clipboard
fun <AllT : Any, EachT, ValueT> OptionWithValues<AllT, EachT, ValueT>.validate(validator: OptionValidator<AllT>): OptionDelegate<AllT>
inline fun <AllT : Any, EachT, ValueT> OptionWithValues<AllT?, EachT, ValueT>.validate(crossinline validator: OptionValidator<AllT>): OptionDelegate<AllT?>

Check the final option value and raise an error if it's not valid.