fun <T> prompt(text: String, default: String? = null, hideInput: Boolean = false, requireConfirmation: Boolean = false, confirmationPrompt: String = "Repeat for confirmation: ", promptSuffix: String = ": ", showDefault: Boolean = true, console: CliktConsole = defaultCliktConsole(), convert: (String) -> T): T?
Prompt a user for text input.
If the user send a terminate signal (e,g, ctrl-c) while the prompt is active, null will be returned.
text
- The text to display for the prompt.
default
- The default value to use for the input. If the user enters a newline without any other
value, default will be returned. This parameter is a String instead of T, since it will be
displayed to the user.
hideInput
- If true, the user's input will not be echoed back to the screen. This is commonly used
for password inputs.
requireConfirmation
- If true, the user will be required to enter the same value twice before it
is accepted.
confirmationPrompt
- The text to show the user when requireConfirmation is true.
promptSuffix
- A delimiter printed between the text and the user's input.
showDefault
- If true, the default value will be shown as part of the prompt.
convert
- A callback that will convert the text that the user enters to the return value of the
function. If the callback raises a UsageError, its message will be printed and the user will be
asked to enter a new value. If default is not null and the user does not input a value, the value
of default will be passed to this callback.
Return
the user's input, or null if the stdin is not interactive and EOF was encountered.
fun prompt(text: String, default: String? = null, hideInput: Boolean = false, requireConfirmation: Boolean = false, confirmationPrompt: String = "Repeat for confirmation: ", promptSuffix: String = ": ", showDefault: Boolean = true): String?