Skip to content

Commit 525609b

Browse files
committed
Update docs for removed deprecated readline() overloads
1 parent d732268 commit 525609b

7 files changed

Lines changed: 40 additions & 110 deletions

File tree

content/docs/aesh/troubleshooting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ List<Completion> completions = Arrays.asList(
219219
new Completion("option2")
220220
);
221221
222-
readline.readline(connection, "$ ", completions, input -> { });
222+
readline.readline(connection, "$ ", input -> { }, completions);
223223
```
224224
225225
2. **Completer is registered:**

content/docs/readline/clipboard.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,9 @@ Actions that write to the clipboard:
127127

128128
To disable automatic clipboard writing, set the `NO_CLIPBOARD` flag:
129129

130-
```java
131-
import org.aesh.readline.ReadlineFlag;
132-
133-
EnumMap<ReadlineFlag, Integer> flags = new EnumMap<>(ReadlineFlag.class);
134-
flags.put(ReadlineFlag.NO_CLIPBOARD, 0);
135-
136-
readline.readline(connection, new Prompt("$ "), input -> {
137-
// handle input
138-
}, null, null, null, null, flags);
139-
```
140-
141-
Or more concisely with `ReadlineRequest` and `ReadlineFlags`:
142-
143130
```java
144131
import org.aesh.readline.ReadlineRequest;
132+
import org.aesh.readline.ReadlineFlag;
145133
import org.aesh.readline.ReadlineFlags;
146134

147135
readline.readline(ReadlineRequest.builder()

content/docs/readline/completion.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class BasicCompletion {
6666

6767
private static void read(TerminalConnection connection, Readline readline,
6868
String prompt, List<Completion> completions) {
69-
readline.readline(connection, prompt, completions, input -> {
69+
readline.readline(connection, prompt, input -> {
7070
if (input != null) {
7171
if (input.equals("exit")) {
7272
connection.close();
@@ -76,7 +76,7 @@ public class BasicCompletion {
7676
read(connection, readline, prompt, completions);
7777
}
7878
}
79-
});
79+
}, completions);
8080
}
8181
}
8282
```
@@ -88,7 +88,7 @@ Update completions based on context:
8888
```java
8989
List<Completion> completions = new ArrayList<>();
9090

91-
readline.readline(connection, prompt, completions, input -> {
91+
readline.readline(connection, prompt, input -> {
9292
if (input != null) {
9393
// Update completions based on context
9494
completions.clear();
@@ -98,7 +98,7 @@ readline.readline(connection, prompt, completions, input -> {
9898
// ...
9999
read(connection, readline, prompt, completions);
100100
}
101-
});
101+
}, completions);
102102
```
103103

104104
## CompletionHandler

content/docs/readline/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public class CompletionExample {
132132

133133
private static void read(TerminalConnection connection, Readline readline,
134134
String prompt, List<Completion> completions) {
135-
readline.readline(connection, prompt, completions, input -> {
135+
readline.readline(connection, prompt, input -> {
136136
if (input != null) {
137137
if (input.equals("exit")) {
138138
connection.close();
@@ -145,7 +145,7 @@ public class CompletionExample {
145145
}
146146
read(connection, readline, prompt, completions);
147147
}
148-
});
148+
}, completions);
149149
}
150150
}
151151
```

content/docs/readline/prompt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Prompt prompt = new Prompt("[user]$ ");
9292
String text = prompt.getPromptCharacters(); // "[user]$ "
9393
```
9494

95-
> **Note:** `getPromptAsString()` is deprecated — use `getPromptCharacters()` instead.
95+
> **Note:** `getPromptAsString()` has been removed — use `getPromptCharacters()` instead.
9696
9797
### getMask()
9898

content/docs/readline/readline-api.md

Lines changed: 30 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -102,87 +102,40 @@ List<Completion> completions = Arrays.asList(
102102
new Completion("list", "List items")
103103
);
104104

105-
readline.readline(connection, prompt, completions, input -> {
105+
readline.readline(connection, "prompt> ", input -> {
106106
// Handle input
107-
});
107+
}, completions);
108108
```
109109

110-
### readline() - With Pre-processors
110+
### ReadlineRequest - Advanced Options
111111

112-
Add input pre-processors that can transform input before it's returned:
112+
For pre-processors, custom history, cursor listeners, or flags, use the `ReadlineRequest` builder:
113113

114114
```java
115+
import org.aesh.readline.ReadlineRequest;
116+
117+
// With pre-processors (e.g. alias expansion)
115118
List<Function<String, Optional<String>>> preProcessors = Arrays.asList(
116-
// Trim whitespace
117-
input -> Optional.of(input.trim()),
118-
119-
// Expand aliases
120119
input -> {
121120
if (input.equals("ll")) {
122121
return Optional.of("ls -l");
123122
}
124123
return Optional.of(input);
125-
},
126-
127-
// Handle empty input
128-
input -> input.isEmpty() ? Optional.empty() : Optional.of(input)
124+
}
129125
);
130126

131-
readline.readline(connection, prompt, completions, preProcessors, input -> {
132-
// input has been processed by all pre-processors
133-
});
134-
```
135-
136-
### readline() - With Custom History
137-
138-
Override the default history for this read operation:
139-
140-
```java
141-
History customHistory = new InMemoryHistory(100);
142-
143-
readline.readline(connection, prompt, completions, preProcessors, customHistory, input -> {
144-
// This read uses customHistory instead of the default
145-
});
146-
```
147-
148-
### readline() - With Cursor Listener
149-
150-
Get callbacks when the cursor position changes:
151-
152-
```java
153-
CursorListener listener = new CursorListener() {
154-
@Override
155-
public void cursorMoved(int oldPos, int newPos) {
156-
// Cursor moved from oldPos to newPos
157-
}
158-
159-
@Override
160-
public void inputChanged(String buffer) {
161-
// Input buffer content changed
162-
}
163-
};
164-
165-
readline.readline(connection, prompt, completions, preProcessors, history, listener, input -> {
166-
// Handle input
167-
});
127+
readline.readline(ReadlineRequest.builder()
128+
.connection(connection)
129+
.prompt(new Prompt("$ "))
130+
.requestHandler(input -> processInput(input))
131+
.completions(completions)
132+
.preProcessors(preProcessors)
133+
.history(customHistory)
134+
.cursorListener(listener)
135+
.build());
168136
```
169137

170-
### readline() - Full Signature
171-
172-
The complete signature with all options:
173-
174-
```java
175-
readline.readline(
176-
Connection conn, // Terminal connection
177-
Prompt prompt, // Prompt to display
178-
Consumer<String> handler, // Input handler callback
179-
List<Completion> completions, // Tab completions
180-
List<Function<String, Optional<String>>> preProcessors, // Input transformers
181-
History history, // Custom history
182-
CursorListener listener, // Cursor events
183-
EnumMap<ReadlineFlag, Integer> flags // Behavior flags
184-
);
185-
```
138+
See the [ReadlineRequest Builder](#readlinerequest-builder) section below for the full list of builder methods.
186139

187140
### ReadlineFlag
188141

@@ -197,11 +150,12 @@ Control readline behavior with flags:
197150
| `NO_CLIPBOARD` | Disable automatic clipboard writes via OSC 52 |
198151

199152
```java
200-
EnumMap<ReadlineFlag, Integer> flags = new EnumMap<>(ReadlineFlag.class);
201-
flags.put(ReadlineFlag.NO_PROMPT_REDRAW_ON_INTR, 1);
202-
203-
readline.readline(connection, prompt, handler, completions,
204-
preProcessors, history, listener, flags);
153+
readline.readline(ReadlineRequest.builder()
154+
.connection(connection)
155+
.prompt(prompt)
156+
.requestHandler(handler)
157+
.flags(ReadlineFlags.of(ReadlineFlag.NO_PROMPT_REDRAW_ON_INTR))
158+
.build());
205159
```
206160

207161
### ReadlineFlags Helper
@@ -222,11 +176,11 @@ ReadlineFlags.of(ReadlineFlag.NO_CLIPBOARD, ReadlineFlag.NO_SHELL_INTEGRATION);
222176
ReadlineFlags.all();
223177
```
224178

225-
> **Note:** `ReadlineFlags` produces `EnumSet<ReadlineFlag>` values. These are accepted by the `ReadlineRequest` builder's `flags()` method and the `readline()` overloads.
179+
> **Note:** `ReadlineFlags` produces `EnumMap<ReadlineFlag, Integer>` values accepted by the `ReadlineRequest` builder's `flags()` method.
226180
227181
### ReadlineRequest Builder
228182

229-
For calls that use several optional parameters, `ReadlineRequest` provides a builder pattern that avoids passing `null` for unused fields:
183+
`ReadlineRequest` provides a builder pattern for calls that need optional parameters like pre-processors, custom history, cursor listeners, or flags:
230184

231185
```java
232186
import org.aesh.readline.ReadlineRequest;
@@ -257,7 +211,7 @@ readline.readline(request);
257211
| `cursorListener(CursorListener)` | `CursorListener` | Cursor movement events |
258212
| `flags(EnumMap<ReadlineFlag, Integer>)` | `EnumMap` | Behavior flags |
259213

260-
> **Note:** The existing `readline()` overloads with positional parameters are deprecated in favor of `ReadlineRequest`. They continue to work but new code should prefer the builder.
214+
> **Tip:** For simple cases, use the convenience methods (`readline(conn, prompt, handler)` or `readline(conn, prompt, handler, completions)`). For anything more complex, use `ReadlineRequest`.
261215
262216
## Completion
263217

@@ -564,17 +518,17 @@ public class InteractiveShell {
564518

565519
List<Completion> completions = getCompletions();
566520

567-
readline.readline(connection, createPrompt(), completions, input -> {
521+
readline.readline(connection, createPrompt(), input -> {
568522
if (input == null) {
569523
// EOF (Ctrl-D)
570524
running = false;
571525
} else if (!input.trim().isEmpty()) {
572526
processCommand(connection, input.trim());
573527
}
574-
528+
575529
// Continue reading
576530
read(connection);
577-
});
531+
}, completions);
578532
}
579533

580534
private Prompt createPrompt() {

content/docs/readline/synchronized-output.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,9 @@ readline.readline(connection, new Prompt("$ "), input -> {
127127

128128
To disable automatic synchronized output, set the `NO_SYNCHRONIZED_OUTPUT` flag:
129129

130-
```java
131-
import org.aesh.readline.ReadlineFlag;
132-
133-
EnumMap<ReadlineFlag, Integer> flags = new EnumMap<>(ReadlineFlag.class);
134-
flags.put(ReadlineFlag.NO_SYNCHRONIZED_OUTPUT, 0);
135-
136-
readline.readline(connection, new Prompt("$ "), input -> {
137-
// handle input
138-
}, null, null, null, null, flags);
139-
```
140-
141-
Or more concisely with `ReadlineRequest` and `ReadlineFlags`:
142-
143130
```java
144131
import org.aesh.readline.ReadlineRequest;
132+
import org.aesh.readline.ReadlineFlag;
145133
import org.aesh.readline.ReadlineFlags;
146134

147135
readline.readline(ReadlineRequest.builder()

0 commit comments

Comments
 (0)