class EagerOption : Option
An Option with no values that is finalized before other types of options. |
|
class FlagOption<T> : OptionDelegate<T>
An Option that has no values. |
|
interface Option
An optional command line parameter that takes a fixed number of values. |
|
class OptionCallTransformContext : Option
A receiver for options transformers. |
|
interface OptionDelegate<out T> : Option, ReadOnlyProperty<CliktCommand, T>
An option that functions as a property delegate |
|
class OptionTransformContext : Option
A receiver for options transformers. |
|
class OptionWithValues<AllT, EachT, ValueT> : OptionDelegate<AllT>
An Option that takes one or more values. |
typealias ArgsTransformer<ValueT, EachT> = OptionCallTransformContext.(List<ValueT>) -> EachT
A callback that transforms all the values for a call to the call type. |
|
typealias CallsTransformer<EachT, AllT> = OptionTransformContext.(List<EachT>) -> AllT
A callback that transforms all of the calls to the final option type. |
|
typealias NullableOption<EachT, ValueT> = OptionWithValues<EachT?, EachT, ValueT> |
|
typealias OptionValidator<AllT> = OptionTransformContext.(AllT) -> Unit
A callback validates the final option type |
|
typealias RawOption = NullableOption<String, String> |
|
typealias ValueTransformer<ValueT> = OptionCallTransformContext.(String) -> ValueT
A callback that transforms a single value from a string to the value type |
fun <T : Any> RawOption.convert(metavar: String = "VALUE", envvarSplit: Regex = this.envvarSplit, conversion: ValueTransformer<T>): NullableOption<T, T>
Convert the option value type. |
|
fun RawOption.counted(): FlagOption<Int>
Turn an option into a flag that counts the number of times the option occurs on the command line. |
|
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): OptionWithValues<EachT, EachT, ValueT>
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>.defaultLazy(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 and use its return value for the option. |
|
fun RawOption.flag(vararg secondaryNames: String, default: Boolean = false): FlagOption<Boolean>
Turn an option into a boolean flag. |
|
fun <EachT : Any, ValueT> NullableOption<EachT, ValueT>.multiple(default: List<EachT> = emptyList()): OptionWithValues<List<EachT>, EachT, ValueT>
Make the option return a list of calls; each item in the list is the value of one call. |
|
fun CliktCommand.option(vararg names: String, help: String = "", metavar: String? = null, : Boolean = false, envvar: String? = null): RawOption
Create a property delegate option. |
|
fun <EachT : Any, ValueT> NullableOption<EachT, ValueT>.pair(): NullableOption<Pair<ValueT, ValueT>, ValueT>
Change to option to take two values, held in a Pair |
|
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. |
|
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. |
|
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. |
|
fun <AllT, EachT : Any, ValueT> NullableOption<EachT, ValueT>.transformAll(transform: CallsTransformer<EachT, AllT>): OptionWithValues<AllT, EachT, ValueT>
Transform all calls to the option to the final option type. |
|
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. |
|
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 |
|
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 |
|
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. |
|
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. |