Skip to content

Index

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

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

Types

Name Summary
ArgsTransformer A callback that transforms all the values for a call to the call type.typealias ArgsTransformer<ValueT, EachT> =OptionCallTransformContext.(List<ValueT>) -> EachT
CallsTransformer A callback that transforms all of the calls to the final option type.typealias CallsTransformer<EachT, AllT> =OptionTransformContext.(List<EachT>) -> AllT
EagerOption An Option with no values that is finalized before other types of options.class EagerOption :StaticallyGroupedOption
FlagConverter A block that converts a flag value from one type to anothertypealias FlagConverter<InT, OutT> =OptionTransformContext.(InT) -> OutT
FlagOption An Option that has no values.class FlagOption<T> :OptionDelegate<T>
NullableOption typealias NullableOption<EachT, ValueT> =OptionWithValues<EachT?, EachT, ValueT>
Option An optional command line parameter that takes a fixed number of values.interface Option
OptionCallTransformContext A receiver for options transformers.class OptionCallTransformContext :Option
OptionDelegate An option that functions as a property delegateinterface OptionDelegate<T> :GroupableOption,ReadOnlyProperty<ParameterHolder, T>
OptionTransformContext A receiver for options transformers.class OptionTransformContext :Option
OptionValidator A callback validates the final option typetypealias OptionValidator<AllT> =OptionTransformContext.(AllT) ->Unit
OptionWithValues An Option that takes one or more values.class OptionWithValues<AllT, EachT, ValueT> :OptionDelegate<AllT>,GroupableOption
RawOption typealias RawOption =NullableOption<String,String>
ValueConverter A block that converts a single value from one type to anothertypealias ValueConverter<InT, ValueT> =OptionCallTransformContext.(InT) -> ValueT
ValueTransformer A callback that transforms a single value from a string to the value typetypealias ValueTransformer<ValueT> =ValueConverter<String, ValueT>
ValueWithDefault A container for a value that can have a default value and can be manually setdata class ValueWithDefault<out T>

Functions

Name Summary
associate Change this option to take multiple values, each split on a delimiter, and converted to a map.funRawOption.associate(delimiter:String= "="):OptionWithValues<Map<String,String>,Pair<String,String>,Pair<String,String>>
convert Convert the option’s value type.fun <InT :Any, ValueT :Any>NullableOption<InT, InT>.convert(metavar:String= "VALUE", envvarSplit:Regex= this.envvarSplit.default, completionCandidates:CompletionCandidates= completionCandidatesWithDefault.default, conversion:ValueConverter<InT, ValueT>):NullableOption<ValueT, ValueT>
fun <InT, OutT>FlagOption<InT>.convert(conversion:FlagConverter<InT, OutT>):FlagOption<OutT>
counted Turn an option into a flag that counts the number of times the option occurs on the command line.funRawOption.counted():FlagOption<Int>
default Set a default value for an option.fun <T :Any>FlagOption<T?>.default(value: T, defaultForHelp:String= value.toString()):FlagOption<T>
If the option is not called on the command line (and is not set in an envvar), use value for the option.fun <EachT :Any, ValueT>NullableOption<EachT, ValueT>.default(value: EachT, defaultForHelp:String= value.toString()):OptionWithValues<EachT, EachT, ValueT>
defaultLazy If the option is not called on the command line (and is not set in an envvar), call the value and use its return value for the option.fun <EachT :Any, ValueT>NullableOption<EachT, ValueT>.defaultLazy(defaultForHelp:String= "", value: () -> EachT):OptionWithValues<EachT, EachT, ValueT>
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>
fun <AllT, EachT, ValueT>OptionWithValues<AllT, EachT, ValueT>.deprecated(message:String? = "", tagName:String? = "deprecated", tagValue:String= "", error:Boolean= false):OptionDelegate<AllT>
eagerOption Add an eager option to this command that, when invoked, runs action.fun <T :CliktCommand> T.eagerOption(name:String, vararg additionalNames:String, help:String= "", hidden:Boolean= false, helpTags:Map<String,String> = emptyMap(), groupName:String? = null, action:OptionTransformContext.() ->Unit): T
fun <T :CliktCommand> T.eagerOption(names:Collection<String>, help:String= "", hidden:Boolean= false, helpTags:Map<String,String> = emptyMap(), groupName:String? = null, action:OptionTransformContext.() ->Unit): T
flag Turn an option into a boolean flag.funRawOption.flag(vararg secondaryNames:String, default:Boolean= false, defaultForHelp:String= ""):FlagOption<Boolean>
multiple Make the option return a list of calls; each item in the list is the value of one call.fun <EachT :Any, ValueT>NullableOption<EachT, ValueT>.multiple(default:List<EachT> = emptyList(), required:Boolean= false):OptionWithValues<List<EachT>, EachT, ValueT>
option Create a property delegate 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(), completionCandidates:CompletionCandidates? = null):RawOption
pair Change this option to take two values, held in a Pair.fun <EachT :Any, ValueT>NullableOption<EachT, ValueT>.pair():NullableOption<Pair<ValueT, ValueT>, ValueT>
prompt If the option isn’t given on the command line, prompt the user for manual input.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>
required If the option is not called on the command line (and is not set in an envvar), throw a MissingParameter.fun <EachT :Any, ValueT>NullableOption<EachT, ValueT>.required():OptionWithValues<EachT, EachT, ValueT>
split Change to option to take any number of values, separated by a regex.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 string delimiter.fun <EachT :Any, ValueT>NullableOption<EachT, ValueT>.split(delimiter:String):OptionWithValues<List<ValueT>?,List<ValueT>, ValueT>
splitPair Split this option’s value into two with a delimiter.funRawOption.splitPair(delimiter:String= "="):NullableOption<Pair<String,String>,Pair<String,String>>
switch Turn an option into a set of flags that each map to a value.fun <T :Any>RawOption.switch(choices:Map<String, T>):FlagOption<T?>
fun <T :Any>RawOption.switch(vararg choices:Pair<String, T>):FlagOption<T?>
toMap Convert this option’s values from a list of pairs into a map with key-value pairs from the list.fun <A, B>OptionWithValues<List<Pair<A, B>>,Pair<A, B>,Pair<A, B>>.toMap():OptionWithValues<Map<A, B>,Pair<A, B>,Pair<A, B>>
transformAll Transform all calls to the option to the final option type.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>
transformValues Change the number of values that this option takes.fun <EachInT :Any, EachOutT :Any, ValueT>NullableOption<EachInT, ValueT>.transformValues(nvalues:Int, transform:ArgsTransformer<ValueT, EachOutT>):NullableOption<EachOutT, ValueT>
triple Change this option to take three values, held in a Triple.fun <EachT :Any, ValueT>NullableOption<EachT, ValueT>.triple():NullableOption<Triple<ValueT, ValueT, ValueT>, ValueT>
unique Make the multiple option return a unique set of callsfun <EachT :Any, ValueT>OptionWithValues<List<EachT>, EachT, ValueT>.unique():OptionWithValues<Set<EachT>, EachT, ValueT>
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>
fun <AllT :Any, EachT, ValueT>OptionWithValues<AllT, EachT, ValueT>.validate(validator:OptionValidator<AllT>):OptionDelegate<AllT>
versionOption Add an eager option to this command that, when invoked, prints a version message and exits.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
withDefault Create a copy with a new default valuefun <T>ValueWithDefault<T>.withDefault(default: T):ValueWithDefault<T>
withExplicit Create a copy with a new explicit valuefun <T>ValueWithDefault<T>.withExplicit(explicit: T):ValueWithDefault<T>
wrapValue funRawOption.~~wrapValue~~(wrapper: (String) ->Any):RawOption
Wrap the option’s values after a conversion is applied.fun <T1 :Any, T2 :Any>NullableOption<T1, T1>.~~wrapValue~~(wrapper: (T1) -> T2):NullableOption<T2, T2>