Skip to content

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

choice

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

Convert the argument based on a fixed set of values.

If ignoreCase is true, the argument will accept values is any mix of upper and lower case.

Example:

argument().choice(mapOf(“foo” to 1, “bar” to 2))

fun Any> RawArgument.choice(vararg choices: Pair<String, T>, ignoreCase: Boolean = false): ProcessedArgument

Convert the argument based on a fixed set of values.

If ignoreCase is true, the argument will accept values is any mix of upper and lower case.

Example:

argument().choice(“foo” to 1, “bar” to 2)

fun RawArgument.choice(vararg choices: String, ignoreCase: Boolean = false): ProcessedArgument<String, String>

Restrict the argument to a fixed set of values.

If ignoreCase is true, the argument will accept values is any mix of upper and lower case. The argument’s final value will always match the case of the corresponding value in choices.

Example:

argument().choice(“foo”, “bar”)

fun Any> RawOption.choice(choices: Map<String, T>, metavar: String = mvar(choices.keys), ignoreCase: Boolean = false): NullableOption

Convert the option based on a fixed set of values.

If ignoreCase is true, the option will accept values is any mix of upper and lower case.

Example:

option().choice(mapOf(“foo” to 1, “bar” to 2))

See Also

com.github.ajalt.clikt.parameters.groups.groupChoice

fun Any> RawOption.choice(vararg choices: Pair<String, T>, metavar: String = mvar(choices.map { it.first }), ignoreCase: Boolean = false): NullableOption

Convert the option based on a fixed set of values.

If ignoreCase is true, the option will accept values is any mix of upper and lower case.

Example:

option().choice(“foo” to 1, “bar” to 2)

See Also

com.github.ajalt.clikt.parameters.groups.groupChoice

fun RawOption.choice(vararg choices: String, metavar: String = mvar(choices.asIterable()), ignoreCase: Boolean = false): NullableOption<String, String>

Restrict the option to a fixed set of values.

If ignoreCase is true, the option will accept values is any mix of upper and lower case. The option’s final value will always match the case of the corresponding value in choices.

Example:

option().choice(“foo”, “bar”)