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


inline fun Any> RawOption.convert(metavar: String = “VALUE”, envvarSplit: Regex = this.envvarSplit.default, completionCandidates: CompletionCandidates = completionCandidatesWithDefault.default, crossinline conversion: ValueTransformer): NullableOption

Convert the option’s 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.


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. This value is can be overridden by passing a value to the option function.

completionCandidates - candidates to use when completing this option in shell autocomplete, if no candidates are specified in option