promptUnless

fun <T : Any> NullableOption<T, T>.promptUnless(text: String, default: String, fallback: () -> T?): OptionWithValues<T, T, T>

Like Clikt's prompt, but the prompt is skipped when fallback yields a value, which is then used as if the user had passed it. Resolution order: the value given on the command line, then fallback, then the interactive prompt. The typed answer, as well as default, goes through the option's own conversion, so validation and error messages match the command-line form; an invalid answer is asked again. A closed input yields default. Like Clikt's prompt, no prompt is shown once another parameter has already failed.

Return

the option with the prompt behavior attached

Parameters

text

prompt text, shown with the default appended when the default is not blank

default

value to use on an empty answer or a closed input, written as the user would type it

fallback

supplier of the value that skips the prompt, or null to prompt