Prompt

abstract class Prompt<T>(prompt: String, val terminal: Terminal, default: T? = null, showDefault: Boolean = true, showChoices: Boolean = true, hideInput: Boolean = false, choices: Collection<T> = emptyList(), promptSuffix: String = ": ", invalidChoiceMessage: String = "Invalid value, choose from ")

The base class for prompts.

ask will print the prompt and ask for a line of user input and return the result of passing that line to convert. If convert instead returns ConversionResult.Invalid, its message will be printed and the user will be asked for input again.

Theme styles used

  • prompt.prompt: applied to the prompt string

  • prompt.choices: applied to the rendered choices values when shown in the prompt

  • prompt.default: applied to the rendered default value when shown in the prompt

  • prompt.choices.invalid: applied to the invalidChoiceMessage when shown

  • danger: applied to the error message returned by convert

Inheritors

Constructors

Link copied to clipboard
constructor(prompt: String, terminal: Terminal, default: T? = null, showDefault: Boolean = true, showChoices: Boolean = true, hideInput: Boolean = false, choices: Collection<T> = emptyList(), 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(): T?

Run the prompt, asking the user for input.