clikt / com.github.ajalt.clikt.parameters.types / choice

choice

fun <T : Any> RawArgument.choice(choices: Map<String, T>): ProcessedArgument<T, T>

Convert the argument based on a fixed set of values.

Example:

argument().choice(mapOf("foo" to 1, "bar" to 2))
fun <T : Any> RawArgument.choice(vararg choices: Pair<String, T>): ProcessedArgument<T, T>

Convert the argument based on a fixed set of values.

Example:

argument().choice("foo" to 1, "bar" to 2)
fun RawArgument.choice(vararg choices: String): ProcessedArgument<String, String>

Restrict the argument to a fixed set of values.

Example:

argument().choice("foo", "bar")
fun <T : Any> RawOption.choice(choices: Map<String, T>, metavar: String = mvar(choices.keys)): NullableOption<T, T>

Convert the option based on a fixed set of values.

Example:

option().choice(mapOf("foo" to 1, "bar" to 2))
fun <T : Any> RawOption.choice(vararg choices: Pair<String, T>, metavar: String = mvar(choices.map { it.first })): NullableOption<T, T>

Convert the option based on a fixed set of values.

Example:

option().choice("foo" to 1, "bar" to 2)
fun RawOption.choice(vararg choices: String, metavar: String = mvar(choices.asIterable())): NullableOption<String, String>

Restrict the option to a fixed set of values.

Example:

option().choice("foo", "bar")