Package-level declarations

Types

Link copied to clipboard

A callback that transforms all the calls to the final option type.

Link copied to clipboard

A block that converts a flag value from one type to another

Link copied to clipboard
Link copied to clipboard
interface Option

An optional command line parameter that takes a fixed number of values.

Link copied to clipboard
class OptionCallTransformContext(val name: String, val option: Option, val context: Context) : Option, TransformContext

A receiver for options transformers.

Link copied to clipboard
Link copied to clipboard
class OptionTransformContext(val option: Option, val context: Context) : Option, TransformContext

A receiver for options transformers.

Link copied to clipboard

A callback validates the final option type

Link copied to clipboard

An Option that takes one or more values.

Link copied to clipboard
Link copied to clipboard

A block that converts a single value from one type to another

Link copied to clipboard

A callback that transforms all values for each call after the individual values have been converted.

Link copied to clipboard

A callback that transforms a single value from a string to the value type

Link copied to clipboard
data class ValueWithDefault<out T>(val explicit: T?, val default: T)

A container for a value that can have a default value and can be manually set

Functions

Link copied to clipboard

Change this option to take multiple values, each split on a delimiter, and converted to a map.

Link copied to clipboard
inline fun <AllT, EachT, ValueT> OptionWithValues<AllT, EachT, ValueT>.check(crossinline lazyMessage: (AllT & Any) -> String = { it.toString() }, crossinline validator: (AllT & Any) -> Boolean): OptionDelegate<AllT>

Check the final argument value and raise an error if it's not valid.

inline fun <AllT, EachT, ValueT> OptionWithValues<AllT, EachT, ValueT>.check(message: String, crossinline validator: (AllT & Any) -> Boolean): OptionDelegate<AllT>

Check the final option value and raise an error if it's not valid.

Link copied to clipboard

Convert this flag's value type.

inline fun <InT : Any, ValueT : Any> NullableOption<InT, InT>.convert(noinline metavar: Context.() -> String = { localization.defaultMetavar() }, completionCandidates: CompletionCandidates? = null, crossinline conversion: ValueConverter<InT, ValueT>): NullableOption<ValueT, ValueT>
inline fun <InT : Any, ValueT : Any> NullableOption<InT, InT>.convert(metavar: String, completionCandidates: CompletionCandidates? = null, crossinline conversion: ValueConverter<InT, ValueT>): NullableOption<ValueT, ValueT>

Convert the option's value type.

Link copied to clipboard

Turn an option into a flag that counts the number of times it occurs on the command line.

Link copied to clipboard
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 for the option.

Link copied to clipboard
inline fun <EachT, ValueT> NullableOption<EachT, ValueT>.defaultLazy(defaultForHelp: String = "", crossinline 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.

Link copied to clipboard
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.

Link copied to clipboard
fun <T : CliktCommand> T.eagerOption(vararg names: 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

Add an eager option to this command that, when invoked, runs action.

Link copied to clipboard
fun RawOption.flag(vararg secondaryNames: String, default: Boolean = false, defaultForHelp: String = ""): OptionWithValues<Boolean, Boolean, Boolean>

Turn an option into a boolean flag.

Link copied to clipboard

Set the help for this option lazily.

Set the help for this option.

Link copied to clipboard
fun <EachT, 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.

Link copied to clipboard

A flag that doesn't have a default value.

Link copied to clipboard
fun ParameterHolder.option(vararg names: String, help: String = "", metavar: String? = null, hidden: Boolean = false, envvar: String? = null, helpTags: Map<String, String> = emptyMap(), completionCandidates: CompletionCandidates? = null, valueSourceKey: String? = null, eager: Boolean = false): RawOption

Create a property delegate option.

Link copied to clipboard
fun <ValueT : Any> NullableOption<ValueT, ValueT>.optionalValue(default: ValueT, acceptsUnattachedValue: Boolean = true): NullableOption<ValueT, ValueT>

Allow this option to be specified with or without an explicit value.

Link copied to clipboard
fun <ValueT : Any> NullableOption<ValueT, ValueT>.optionalValueLazy(acceptsUnattachedValue: Boolean = true, default: () -> ValueT): NullableOption<ValueT, ValueT>

Allow this option to be specified with or without an explicit value.

Link copied to clipboard

Change this option to take two values, held in a Pair.

Link copied to clipboard
fun OptionWithValues<Boolean, Boolean, Boolean>.prompt(text: String, default: Boolean? = null, uppercaseDefault: Boolean = true, showChoices: Boolean = true, choiceStrings: List<String> = listOf("y", "n"), promptSuffix: String = ": ", invalidChoiceMessage: String = "Invalid value, choose from "): OptionWithValues<Boolean, Boolean, Boolean>
fun <T : Any> NullableOption<T, T>.prompt(text: String? = null, default: T? = null, hideInput: Boolean = false, promptSuffix: String = ": ", showDefault: Boolean = true, requireConfirmation: Boolean = false, confirmationPrompt: String = "Repeat for confirmation", confirmationMismatchMessage: String = "Values do not match, try again"): OptionWithValues<T, T, T>

If the option isn't given on the command line, prompt the user for manual input.

Link copied to clipboard

If the option is not called on the command line (and is not set in an envvar), throw a MissingOption.

Link copied to clipboard

Change to option to take any number of values, separated by a string delimiter.

Change to option to take any number of values, separated by a regex.

Link copied to clipboard

Split this option's value into two with a delimiter.

Link copied to clipboard
fun <T : Any> RawOption.switch(vararg choices: Pair<String, T>): NullableOption<T, String>

Turn an option into a set of flags that each map to a value.

Link copied to clipboard

Convert this option's values from a list of pairs into a map with key-value pairs from the list.

Link copied to clipboard
fun <AllT, EachT, ValueT> NullableOption<EachT, ValueT>.transformAll(defaultForHelp: String? = this.helpTags[HelpFormatter.Tags.DEFAULT], showAsRequired: Boolean = HelpFormatter.Tags.REQUIRED in this.helpTags, transform: AllTransformer<EachT, AllT>): OptionWithValues<AllT, EachT, ValueT>

Transform all calls to the option to the final option type.

Link copied to clipboard

Change the number of values that this option takes.

Link copied to clipboard

Change this option to take three values, held in a Triple.

Link copied to clipboard

Make a multiple option return a unique set of values

Link copied to clipboard

Check the final option value and raise an error if it's not valid.

Link copied to clipboard
fun <ValueT> NullableOption<ValueT, ValueT>.varargValues(min: Int = 1, max: Int = Int.MAX_VALUE): NullableOption<List<ValueT>, ValueT>

Change this option to take a variable number of values.

Link copied to clipboard
inline fun <T : CliktCommand> T.versionOption(version: String, help: String = "Show the version and exit", names: Set<String> = setOf("--version"), crossinline message: (String) -> String = { "$commandName version $it" }): T

Add an eager option to this command that, when invoked, prints a version message and exits.

Link copied to clipboard

Create a copy with a new default value

Link copied to clipboard

Create a copy with a new explicit value