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

FlagOption

class FlagOption : OptionDelegate

An Option that has no values.

Constructors

Name Summary
<init> An Option that has no values.FlagOption(names:Set<String>, secondaryNames:Set<String>, help:String, hidden:Boolean, helpTags:Map<String,String>, envvar:String?, transformEnvvar:OptionTransformContext.(String) -> T, transformAll:CallsTransformer<String, T>, validator:OptionValidator<T>)

Properties

Name Summary
envvar The name of the environment variable for this option. Overrides automatic names.val envvar:String?
groupName The name of the group, or null if this option should not be grouped in the help output.var groupName:String?
help The description of this option, usually a single line.val help:String
helpTags Extra information about this option to pass to the help formatter.val helpTags:Map<String,String>
hidden If true, this option should not appear in help output.val hidden:Boolean
metavar A name representing the values for this option that can be displayed to the user.val metavar:String?
names The names that can be used to invoke this option. They must start with a punctuation character.var names:Set<String>
nvalues The number of values that must be given to this option.val nvalues:Int
parameterGroup The group that this option belongs to, or null. Set by the group.var parameterGroup:ParameterGroup?
parser The parser for this option’s values.val parser:FlagOptionParser
secondaryNames Names that can be used for a secondary purpose, like disabling flag options.val secondaryNames:Set<String>
transformAll Called to transform all invocations of this option into the final option type.val transformAll:CallsTransformer<String, T>
transformEnvvar Called to transform string values from envvars into the option type.val transformEnvvar:OptionTransformContext.(String) -> T
validator val validator:OptionValidator<T>
value The value for this option.var value: T

Functions

Name Summary
copy Create a new option that is a copy of this one with different 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.help, hidden:Boolean= this.hidden, helpTags:Map<String,String> = this.helpTags, envvar:String? = this.envvar):FlagOption<T>
Create a new option that is a copy of this one with the same transforms.fun copy(validator:OptionValidator<T> = this.validator, names:Set<String> = this.names, secondaryNames:Set<String> = this.secondaryNames, help:String= this.help, hidden:Boolean= this.hidden, helpTags:Map<String,String> = this.helpTags, envvar:String? = this.envvar):FlagOption<T>
finalize Called after this command’s argv is parsed to transform and store the option’s value.fun finalize(context:Context, invocations:List<Invocation>):Unit
postValidate Called after all of a command’s parameters have been finalized to perform validation of the final value.fun postValidate(context:Context):Unit
provideDelegate Implementations must call ParameterHolder.registerOptionoperator fun provideDelegate(thisRef:ParameterHolder, prop:KProperty<*>):ReadOnlyProperty<ParameterHolder, T>

Extension Functions

Name Summary
default Set a default value for a option.fun <T :Any>FlagOption<T?>.default(value: T):FlagOption<T>
deprecated Mark this option as deprecated in the help output.fun <T>FlagOption<T>.deprecated(message:String? = "", tagName:String? = "deprecated", tagValue:String= "", error:Boolean= false):OptionDelegate<T>
validate Check the final option value and raise an error if it’s not valid.fun <T :Any>FlagOption<T>.validate(validator:OptionValidator<T>):OptionDelegate<T>