valepakh commented on code in PR #7372:
URL: https://github.com/apache/ignite-3/pull/7372#discussion_r2685659216
##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/core/repl/executor/ReplExecutorImpl.java:
##########
@@ -107,65 +140,42 @@ public void execute(Repl repl) {
repl.customizeTerminal(terminal);
IgnitePicocliCommands picocliCommands =
createPicocliCommands(repl);
- SystemRegistryImpl registry = new SystemRegistryImpl(
- repl.getParser() == null
- ? parser
- : repl.getParser(),
- terminal,
- workDirProvider,
- null
- );
-
+ SystemRegistryImpl registry = createRegistry(repl);
registry.setCommandRegistries(picocliCommands);
- LineReader reader = createReader(
- repl.getCompleter() != null
- ? repl.getCompleter()
- : registry.completer(),
- repl.getHighlighter() != null
- ? repl.getHighlighter()
- : new DefaultHighlighter(),
- repl.getParser() != null
- ? repl.getParser()
- : parser
- );
- if (repl.getHistoryFileName() != null) {
- reader.variable(LineReader.HISTORY_FILE,
StateFolderProvider.getStateFile(repl.getHistoryFileName()));
- }
-
+ LineReader reader = createReader(repl, registry);
RegistryCommandExecutor executor = new
RegistryCommandExecutor(parser, picocliCommands.getCmd());
setupWidgets(repl, registry, reader);
-
repl.onStart();
- while (!interrupted.get()) {
- try {
- executor.cleanUp();
- String prompt = repl.getPromptProvider().getPrompt();
- String line = reader.readLine(prompt, null,
(MaskingCallback) null, null);
- if (line.isEmpty()) {
- continue;
- }
-
- repl.getPipeline(executor, exceptionHandlers,
line).runPipeline();
- } catch (Throwable t) {
- exceptionHandlers.handleException(System.err::println, t);
- }
- }
+ runReplLoop(repl, picocliCommands, executor, reader);
+
reader.getHistory().save();
} catch (Throwable t) {
exceptionHandlers.handleException(System.err::println, t);
}
}
- private static void setupWidgets(Repl repl, SystemRegistryImpl registry,
LineReader reader) {
- if (repl.isTailTipWidgetsEnabled()) {
- createTailTipWidgets(registry, reader);
- } else if (repl.isAutosuggestionsWidgetsEnabled()) {
- AutosuggestionWidgets widgets = new AutosuggestionWidgets(reader);
- widgets.enable();
+ private SystemRegistryImpl createRegistry(Repl repl) {
+ return new SystemRegistryImpl(
+ repl.getParser() == null ? parser : repl.getParser(),
Review Comment:
Let's make this consistent with the `createReader`
```suggestion
repl.getParser() != null ? repl.getParser() : parser,
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]