Class ReadlineRequest.Builder
java.lang.Object
org.aesh.readline.ReadlineRequest.Builder
- Enclosing class:
ReadlineRequest
Builder for constructing
ReadlineRequest instances.
The connection(Connection), prompt(Prompt), and
requestHandler(Consumer) fields are required.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a newReadlineRequestfrom this builder's configuration.completions(List<org.aesh.readline.completion.Completion> completions) Sets the list of completions for tab completion.connection(org.aesh.terminal.Connection connection) Sets the terminal connection (required).cursorListener(CursorListener cursorListener) Sets the cursor listener to receive cursor movement events.flags(EnumMap<ReadlineFlag, Integer> flags) Sets the readline flags controlling behavior.Sets the history instance to use for this readline operation.Sets the list of input pre-processors.Sets the prompt to display using a string (required).prompt(org.aesh.readline.prompt.Prompt prompt) Sets the prompt to display (required).promptSupplier(Supplier<org.aesh.readline.prompt.Prompt> promptSupplier) Sets a supplier that provides the prompt dynamically.requestHandler(Consumer<String> requestHandler) Sets the callback to receive the completed input line (required).
-
Method Details
-
connection
Sets the terminal connection (required).- Parameters:
connection- the terminal connection- Returns:
- this builder
-
prompt
Sets the prompt to display (required).- Parameters:
prompt- the prompt- Returns:
- this builder
-
prompt
Sets the prompt to display using a string (required).- Parameters:
prompt- the prompt string- Returns:
- this builder
-
promptSupplier
public ReadlineRequest.Builder promptSupplier(Supplier<org.aesh.readline.prompt.Prompt> promptSupplier) Sets a supplier that provides the prompt dynamically.The supplier is called once at the start of each
readline()cycle, allowing the prompt to change between invocations. This is useful for displaying dynamic information like command execution time, git branch, or environment status.If both
promptandpromptSupplierare set, the supplier takes precedence.Example:
ReadlineRequest.builder() .promptSupplier(() -> Prompt.builder() .line("myapp on " + gitBranch()) .line("❯ ") .build()) .requestHandler(line -> { ... }) .build();- Parameters:
promptSupplier- the prompt supplier- Returns:
- this builder
-
requestHandler
Sets the callback to receive the completed input line (required).- Parameters:
requestHandler- the request handler- Returns:
- this builder
-
completions
public ReadlineRequest.Builder completions(List<org.aesh.readline.completion.Completion> completions) Sets the list of completions for tab completion.- Parameters:
completions- the completions list- Returns:
- this builder
-
preProcessors
-
history
Sets the history instance to use for this readline operation.- Parameters:
history- the history instance- Returns:
- this builder
-
cursorListener
Sets the cursor listener to receive cursor movement events.- Parameters:
cursorListener- the cursor listener- Returns:
- this builder
-
flags
Sets the readline flags controlling behavior.- Parameters:
flags- the flags map- Returns:
- this builder
-
build
Builds a newReadlineRequestfrom this builder's configuration.- Returns:
- a new ReadlineRequest instance
- Throws:
NullPointerException- if connection, prompt, or requestHandler is null
-