convert

inline fun <InT : Any, ValueT : Any> ProcessedArgument<InT, InT>.convert(completionCandidates: CompletionCandidates? = explicitCompletionCandidates, crossinline conversion: ArgValueConverter<InT, ValueT>): ProcessedArgument<ValueT, ValueT>

Convert the argument's values.

The conversion is called once for each value given. 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.

You can call convert more than once to wrap the result of the previous convert, but it cannot be called after transformAll (e.g. multiple) or transformValues (e.g. pair).

Example

val bd: BigDecimal by argument().convert { it.toBigDecimal() }
val fileText: ByteArray by argument().file().convert { it.readBytes() }

Parameters

completionCandidates

candidates to use when completing this argument in shell autocomplete, if no candidates are specified in argument