clikt / com.github.ajalt.clikt.parameters.options / FlagOption

FlagOption

class FlagOption<T> : OptionDelegate<T>

An Option that has no values.

Constructors

<init>

FlagOption(names: Set<String>, secondaryNames: Set<String>, help: String, hidden: Boolean, envvar: String?, transformEnvvar: OptionTransformContext.(String) -> T, transformAll: CallsTransformer<String, T>)

An Option that has no values.

Properties

envvar

val envvar: String?

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

help

val help: String

The description of this option, usually a single line.

hidden

val hidden: Boolean

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

metavar

val metavar: String?

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

names

var names: Set<String>

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

nvalues

val nvalues: Int

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

parser

val parser: FlagOptionParser

The parser for this option's values.

secondaryNames

val secondaryNames: Set<String>

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

transformAll

val transformAll: CallsTransformer<String, T>

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

transformEnvvar

val transformEnvvar: OptionTransformContext.(String) -> T

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

Functions

finalize

fun finalize(context: Context, invocations: List<Invocation>): Unit

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

getValue

fun getValue(thisRef: CliktCommand, property: KProperty<*>): T

provideDelegate

operator fun provideDelegate(thisRef: CliktCommand, prop: KProperty<*>): ReadOnlyProperty<CliktCommand, T>

Implementations must call CliktCommand.registerOption

Extension Functions

default

fun <T : Any> FlagOption<T?>.default(value: T): FlagOption<T>

Set a default value for a option.

validate

fun <T : Any> FlagOption<T>.validate(validator: OptionValidator<T>): OptionDelegate<T>

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