FlagOption

An Option that has no values.

Functions

Link copied to clipboard
fun copy(validator: OptionValidator<T> = this.validator, names: Set<String> = this.names, secondaryNames: Set<String> = this.secondaryNames, help: String = this.optionHelp, hidden: Boolean = this.hidden, helpTags: Map<String, String> = this.helpTags, valueSourceKey: String? = this.valueSourceKey, envvar: String? = this.envvar): FlagOption<T>

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

fun <T> copy(transformEnvvar: OptionTransformContext.(String) -> T, transformAll: CallsTransformer<String, T>, validator: OptionValidator<T>, names: Set<String> = this.names, secondaryNames: Set<String> = this.secondaryNames, help: String = this.optionHelp, hidden: Boolean = this.hidden, helpTags: Map<String, String> = this.helpTags, valueSourceKey: String? = this.valueSourceKey, envvar: String? = this.envvar): FlagOption<T>

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 operator override fun getValue(thisRef: ParameterHolder, property: KProperty<*>): T
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

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<*>): ReadOnlyProperty<ParameterHolder, T>

Implementations must call ParameterHolder.registerOption

Properties

Link copied to clipboard

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

Link copied to clipboard

The name of the environment variable for this option. Overrides automatic names.

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
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: FlagOptionParser

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

Called to transform all invocations of this option into the final option type.

Link copied to clipboard

Called to transform string values from envvars and value sources into the option type.

Link copied to clipboard
Link copied to clipboard
open override var value: T

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

Extensions

Link copied to clipboard
inline fun <InT, OutT> FlagOption<InT>.convert(crossinline conversion: FlagConverter<InT, OutT>): FlagOption<OutT>

Convert the option's value type.

Link copied to clipboard
fun <T : Any> FlagOption<T?>.default(value: T, defaultForHelp: String = value.toString()): FlagOption<T>

Set a default value for an option.

Link copied to clipboard
inline fun <T : Any> FlagOption<T?>.defaultLazy(defaultForHelp: String = "", crossinline value: () -> T): FlagOption<T>

Set a default value for an option from a lazy builder which is only called if the default value is used.

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

Mark this option as deprecated in the help output.

Link copied to clipboard
fun <T> FlagOption<T>.help(help: String): FlagOption<T>

Set the help for this option.

Link copied to clipboard

If the option is not called on the command line (and is not set in an envvar), throw a MissingOption.

Link copied to clipboard

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