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

convert

inline fun <T : Any> RawOption.convert(metavar: String = "VALUE", envvarSplit: Regex = this.envvarSplit, crossinline conversion: ValueTransformer<T>): NullableOption<T, T>

Convert the option value type.

The conversion is called once for each value in each invocation of the option. If any errors are thrown, they are caught and a BadParameterValue is thrown with the error message. You can call fail to throw a BadParameterValue manually.

Parameters

metavar - The metavar for the type. Overridden by a metavar passed to option.

envvarSplit - If the value is read from an envvar, the pattern to split the value on. The default splits on whitespace.