YesNoPrompt

class YesNoPrompt(prompt: String, terminal: Terminal, default: Boolean? = null, uppercaseDefault: Boolean = true, showChoices: Boolean = true, choiceStrings: List<String> = listOf("y", "n"), promptSuffix: String = ": ", invalidChoiceMessage: String = "Invalid value, choose from ") : Prompt<Boolean>

A boolean prompt that asks for a yes or no response.

Parameters

prompt

The message asking for input to show the user

terminal

The terminal to use

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.

Constructors

Link copied to clipboard
constructor(prompt: String, terminal: Terminal, default: Boolean? = null, uppercaseDefault: Boolean = true, showChoices: Boolean = true, choiceStrings: List<String> = listOf("y", "n"), promptSuffix: String = ": ", invalidChoiceMessage: String = "Invalid value, choose from ")

Properties

Link copied to clipboard

The terminal to use

Functions

Link copied to clipboard
open fun ask(): Boolean?

Run the prompt, asking the user for input.