prompt

fun <T : Any> NullableOption<T, T>.prompt(text: String? = null, default: T? = null, hideInput: Boolean = false, promptSuffix: String = ": ", showDefault: Boolean = true, requireConfirmation: Boolean = false, confirmationPrompt: String = "Repeat for confirmation", confirmationMismatchMessage: String = "Values do not match, try again"): OptionWithValues<T, T, T>

If the option isn't given on the command line, prompt the user for manual input.

Note that if the option is defined with a validate or check, that validation will be run each time the user enters a value. This means that, unlike normal options, the validation for prompt options cannot reference other parameters.

Parameters

text

The text to prompt the user with

default

The default value to use if no input is given. If null, the prompt will be repeated until input is given.

hideInput

If true, user input will not be shown on the screen. Useful for passwords and sensitive input.

promptSuffix

Text to display directly after text. Defaults to ": ".

showDefault

Show default to the user in the prompt.


fun OptionWithValues<Boolean, Boolean, Boolean>.prompt(text: String, default: Boolean? = null, uppercaseDefault: Boolean = true, showChoices: Boolean = true, choiceStrings: List<String> = listOf("y", "n"), promptSuffix: String = ": ", invalidChoiceMessage: String = "Invalid value, choose from "): OptionWithValues<Boolean, Boolean, Boolean>

If the option isn't given on the command line, prompt the user for manual input.

Parameters

text

The message asking for input to show the user

default

The value to return if the user enters an empty line, or null to require a value

uppercaseDefault

If true and default is not null, the default choice will be shown in uppercase.

showChoices

If true, the choices will be added to the prompt

choiceStrings

The strings to accept for true and false inputs

promptSuffix

A string to append after prompt when showing the user the prompt

invalidChoiceMessage

The message to show the user if they enter a value that isn't one of the choiceStrings.