Skip to content

Home

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

Package com.github.ajalt.clikt.parameters.options

Types

Name Summary
EagerOption class EagerOption :Option
An Option with no values that is finalized before other types of options.
FlagOption class FlagOption<T> :OptionDelegate<T>
An Option that has no values.
Option interface Option
An optional command line parameter that takes a fixed number of values.
OptionCallTransformContext class OptionCallTransformContext :Option
A receiver for options transformers.
OptionDelegate interface OptionDelegate<T> :GroupableOption,ReadOnlyProperty<ParameterHolder,T>
An option that functions as a property delegate
OptionTransformContext class OptionTransformContext :Option
A receiver for options transformers.
OptionWithValues class OptionWithValues<AllT, EachT, ValueT> :OptionDelegate<AllT>,GroupableOption
An Option that takes one or more values.
ValueWithDefault data class ValueWithDefault<out T>
A container for a value that can have a default value and can be manually set

Type Aliases

Name Summary
ArgsTransformer typealias ArgsTransformer<ValueT, EachT> =OptionCallTransformContext.(List<ValueT>) ->EachT
A callback that transforms all the values for a call to the call type.
CallsTransformer typealias CallsTransformer<EachT, AllT> =OptionTransformContext.(List<EachT>) ->AllT
A callback that transforms all of the calls to the final option type.
NullableOption typealias NullableOption<EachT, ValueT> =OptionWithValues<EachT?,EachT,ValueT>
OptionValidator typealias OptionValidator<AllT> =OptionTransformContext.(AllT) ->Unit
A callback validates the final option type
RawOption typealias RawOption =NullableOption<String,String>
ValueTransformer typealias ValueTransformer<ValueT> =OptionCallTransformContext.(String) ->ValueT
A callback that transforms a single value from a string to the value type

Functions

Name Summary
convert fun <T :Any>RawOption.convert(metavar:String= "VALUE", envvarSplit:Regex= this.envvarSplit.default, completionCandidates:CompletionCandidates= this.completionCandidates, conversion:ValueTransformer<T>):NullableOption<T,T>
Convert the option value type.
counted funRawOption.counted():FlagOption<Int>
Turn an option into a flag that counts the number of times the option occurs on the command line.
default fun <T :Any>FlagOption<T?>.default(value:T):FlagOption<T>
Set a default value for a option.fun <EachT :Any, ValueT>NullableOption<EachT,ValueT>.default(value:EachT, defaultForHelp:String= value.toString()):OptionWithValues<EachT,EachT,ValueT>
If the option is not called on the command line (and is not set in an envvar), use value, com.github.ajalt.clikt.parameters.options.default.EachT, kotlin.String)/value) for the option.
defaultLazy fun <EachT :Any, ValueT>NullableOption<EachT,ValueT>.defaultLazy(defaultForHelp:String= "", value: () ->EachT):OptionWithValues<EachT,EachT,ValueT>
If the option is not called on the command line (and is not set in an envvar), call the value, kotlin.String, kotlin.Function0((com.github.ajalt.clikt.parameters.options.defaultLazy.EachT)))/value) and use its return value for the option.
deprecated fun <T>FlagOption<T>.deprecated(message:String? = "", tagName:String? = "deprecated", tagValue:String= "", error:Boolean= false):OptionDelegate<T>
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.
flag funRawOption.flag(vararg secondaryNames:String, default:Boolean= false):FlagOption<Boolean>
Turn an option into a boolean flag.
multiple fun <EachT :Any, ValueT>NullableOption<EachT,ValueT>.multiple(default:List<EachT> = emptyList(), required:Boolean= false):OptionWithValues<List<EachT>,EachT,ValueT>
Make the option return a list of calls; each item in the list is the value of one call.
option funParameterHolder.option(vararg names:String, help:String= "", metavar:String? = null, hidden:Boolean= false, envvar:String? = null, envvarSplit:Regex? = null, helpTags:Map<String,String> = emptyMap()):RawOption
Create a property delegate option.
pair fun <EachT :Any, ValueT>NullableOption<EachT,ValueT>.pair():NullableOption<Pair<ValueT,ValueT>,ValueT>
Change to option to take two values, held in a Pair.
prompt fun <T :Any>NullableOption<T,T>.prompt(text:String? = null, default:String? = null, hideInput:Boolean= false, requireConfirmation:Boolean= false, confirmationPrompt:String= "Repeat for confirmation: ", promptSuffix:String= ": ", showDefault:Boolean= true):OptionWithValues<T,T,T>
If the option isn’t given on the command line, prompt the user for manual input.
required fun <EachT :Any, ValueT>NullableOption<EachT,ValueT>.required():OptionWithValues<EachT,EachT,ValueT>
If the option is not called on the command line (and is not set in an envvar), throw a MissingParameter.
split fun <EachT :Any, ValueT>NullableOption<EachT,ValueT>.split(regex:Regex):OptionWithValues<List<ValueT>?,List<ValueT>,ValueT>
Change to option to take any number of values, separated by a regex, kotlin.text.Regex)/regex).fun <EachT :Any, ValueT>NullableOption<EachT,ValueT>.split(delimiter:String):OptionWithValues<List<ValueT>?,List<ValueT>,ValueT>
Change to option to take any number of values, separated by a string delimiter, kotlin.String)/delimiter).
switch fun <T :Any>RawOption.switch(choices:Map<String,T>):FlagOption<T?>
fun <T :Any>RawOption.switch(vararg choices:Pair<String,T>):FlagOption<T?>
Turn an option into a set of flags that each map to a value.
transformAll fun <AllT, EachT :Any, ValueT>NullableOption<EachT,ValueT>.transformAll(defaultForHelp:String? = this.helpTags[HelpFormatter.Tags.DEFAULT], showAsRequired:Boolean= HelpFormatter.Tags.REQUIRED in this.helpTags, transform:CallsTransformer<EachT,AllT>):OptionWithValues<AllT,EachT,ValueT>
Transform all calls to the option to the final option type.
transformValues fun <EachInT :Any, EachOutT :Any, ValueT>NullableOption<EachInT,ValueT>.transformValues(nvalues:Int, transform:ArgsTransformer<ValueT,EachOutT>):NullableOption<EachOutT,ValueT>
Change the number of values that this option takes.
triple fun <EachT :Any, ValueT>NullableOption<EachT,ValueT>.triple():NullableOption<Triple<ValueT,ValueT,ValueT>,ValueT>
Change to option to take three values, held in a Triple.
unique fun <EachT :Any, ValueT>OptionWithValues<List<EachT>,EachT,ValueT>.unique():OptionWithValues<Set<EachT>,EachT,ValueT>
Make the multiple option return a unique set of calls
validate fun <T :Any>FlagOption<T>.validate(validator:OptionValidator<T>):OptionDelegate<T>
fun <AllT :Any, EachT, ValueT>OptionWithValues<AllT,EachT,ValueT>.validate(validator:OptionValidator<AllT>):OptionDelegate<AllT>
Check the final option value and raise an error if it’s not valid.
versionOption fun <T :CliktCommand>T.versionOption(version:String, help:String= "Show the version and exit", names:Set<String> = setOf("--version"), message: (String) ->String= { "$commandName version $it" }):T
Add an eager option to this command that, when invoked, prints a version message and exits.