FlagOption

class FlagOption<T> : OptionDelegate<T>

An Option that has no values.

Functions

copy
Link copied to clipboard
common
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.
finalize
Link copied to clipboard
common
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.
getValue
Link copied to clipboard
common
open operator override fun getValue(thisRef: ParameterHolder, property: KProperty<*>): T
metavar
Link copied to clipboard
common
open override fun metavar(context: Context): String?
A name representing the values for this option that can be displayed to the user.
parameterHelp
Link copied to clipboard
common
open fun parameterHelp(context: Context): HelpFormatter.ParameterHelp.Option?
Information about this option for the help output.
postValidate
Link copied to clipboard
common
open override fun postValidate(context: Context)
Called after all of a command's parameters have been finalized to perform validation of the final value.
provideDelegate
Link copied to clipboard
common
open operator override fun provideDelegate(thisRef: ParameterHolder, prop: KProperty<*>): ReadOnlyProperty<ParameterHolder, T>
Implementations must call ParameterHolder.registerOption

Properties

completionCandidates
Link copied to clipboard
common
open val completionCandidates: CompletionCandidates
Optional set of strings to use when the user invokes shell autocomplete on a value for this option.
envvar
Link copied to clipboard
common
val envvar: String?
The name of the environment variable for this option.
groupName
Link copied to clipboard
common
open override var groupName: String? = null
The name of the group, or null if this option should not be grouped in the help output.
helpTags
Link copied to clipboard
common
open override val helpTags: Map<String, String>
Extra information about this option to pass to the help formatter.
hidden
Link copied to clipboard
common
open override val hidden: Boolean
If true, this option should not appear in help output.
names
Link copied to clipboard
common
open override var names: Set<String>
The names that can be used to invoke this option.
nvalues
Link copied to clipboard
common
open override val nvalues: Int
The number of values that must be given to this option.
optionHelp
Link copied to clipboard
common
open override val optionHelp: String
The description of this option, usually a single line.
parameterGroup
Link copied to clipboard
common
open override var parameterGroup: ParameterGroup? = null
The group that this option belongs to, or null.
parser
Link copied to clipboard
common
open override val parser: FlagOptionParser
The parser for this option's values.
secondaryNames
Link copied to clipboard
common
open override val secondaryNames: Set<String>
Names that can be used for a secondary purpose, like disabling flag options.
transformAll
Link copied to clipboard
common
val transformAll: CallsTransformer<String, T>
Called to transform all invocations of this option into the final option type.
transformEnvvar
Link copied to clipboard
common
val transformEnvvar: OptionTransformContext.(String) -> T
Called to transform string values from envvars and value sources into the option type.
validator
Link copied to clipboard
common
val validator: OptionValidator<T>
value
Link copied to clipboard
common
open override var value: T
The value for this option.
valueSourceKey
Link copied to clipboard
common
open override val valueSourceKey: String?
Optional explicit key to use when looking this option up from a ValueSource

Extensions

convert
Link copied to clipboard
common
inline fun <InT, OutT> FlagOption<InT>.convert(crossinline conversion: FlagConverter<InT, OutT>): FlagOption<OutT>
Convert the option's value type.
default
Link copied to clipboard
common
fun <T : Any> FlagOption<T?>.default(value: T, defaultForHelp: String = value.toString()): FlagOption<T>
Set a default value for an option.
defaultLazy
Link copied to clipboard
common
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.
deprecated
Link copied to clipboard
common
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.
help
Link copied to clipboard
common
fun <T> FlagOption<T>.help(help: String): FlagOption<T>
Set the help for this option.
required
Link copied to clipboard
common
fun <T : Any> FlagOption<T?>.required(): FlagOption<T>
If the option is not called on the command line (and is not set in an envvar), throw a MissingOption.
validate
Link copied to clipboard
common
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.