promptOrDefault

fun <T : Any> NullableOption<T, T>.promptOrDefault(text: String, default: String = ""): OptionWithValues<T, T, T>

Like Clikt's prompt, but a closed input, such as a non-interactive shell or a pipe at its end, yields default instead of failing with a missing-option error.

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

See also