Package org.aesh.readline
Class Prompt.PromptBuilder
java.lang.Object
org.aesh.readline.Prompt.PromptBuilder
- Enclosing class:
Prompt
Builder for creating
Prompt instances with a fluent API.
The builder supports all the input combinations that the Prompt constructors accept. When multiple prompt sources are set, the precedence is (highest to lowest):
characters(List<TerminalCharacter>)terminalString(TerminalString)promptCodePoints(int[])promptString(String), optionally combined withansiString
Example usage:
Prompt p = Prompt.builder()
.message("$ ")
.mask('*')
.build();
-
Method Summary
Modifier and TypeMethodDescriptionSets the ANSI-formatted string for display.build()Builds a newPromptinstance from the configured parameters.characters(List<TerminalCharacter> characters) Sets the prompt from a list of individually formattedTerminalCharacters.mask(char mask) Sets the mask character for hiding user input (e.g., for passwords).Sets the prompt text.promptCodePoints(int[] codePoints) Sets the prompt as an array of Unicode code points.terminalString(TerminalString terminalString) Sets the prompt from aTerminalStringwith ANSI formatting.
-
Method Details
-
message
Sets the prompt text.- Parameters:
prompt- the prompt text- Returns:
- this builder
-
ansi
Sets the ANSI-formatted string for display. This is used in combination withmessage(String)to provide a separate display representation with ANSI escape codes.- Parameters:
ansiString- the ANSI-formatted string- Returns:
- this builder
-
mask
Sets the mask character for hiding user input (e.g., for passwords).- Parameters:
mask- the masking character- Returns:
- this builder
-
promptCodePoints
Sets the prompt as an array of Unicode code points.- Parameters:
codePoints- the prompt code points- Returns:
- this builder
-
terminalString
Sets the prompt from aTerminalStringwith ANSI formatting.- Parameters:
terminalString- the terminal string containing the prompt- Returns:
- this builder
-
characters
Sets the prompt from a list of individually formattedTerminalCharacters.- Parameters:
characters- the list of terminal characters- Returns:
- this builder
-
build
Builds a newPromptinstance from the configured parameters.The builder selects the appropriate constructor based on which fields have been set, using the precedence order: characters, terminalString, promptCodePoints, promptString.
- Returns:
- a new Prompt instance
-