Package com.helixframework.console
Class Prompt
java.lang.Object
com.helixframework.console.Prompt
Prompt class represents a command line prompt that reads user input from the console.
The Prompt class provides methods to customize the prompt message, prefix, suffix, default value,
required input, and text colors. It uses the ConsoleReader class for reading user input.
Example usage:
Prompt prompt = Prompt.builder(consoleReader, "Enter your name")
.promptPrefix("> ")
.promptSuffix(":")
.defaultValue("John Doe")
.optional()
.promptColor(Colors.GREEN)
.defaultValueColor(Colors.YELLOW)
.build();
String name = prompt.read();
The Prompt class provides a fluent builder API to configure and create instances of Prompt.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class for creating Prompt objects. -
Method Summary
Modifier and TypeMethodDescriptionstatic Prompt.BuilderCreates a new instance of Builder class to build a Prompt object.read()Reads user input from the ConsoleReader object.
-
Method Details
-
builder
Creates a new instance of Builder class to build a Prompt object.- Parameters:
reader- the ConsoleReader object to read user input fromprompt- the prompt message displayed to the user- Returns:
- a new instance of Builder class
-
read
Reads user input from the ConsoleReader object.- Returns:
- the user input as a String
- Throws:
IOException- if there is an error reading user input
-