forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#19760 from aloubyansky/exclude-jline-fro…
…m-maven-plugin Fix dev mode launch on Windows, replace jline with Aesh in the quarkus-maven-plugin
- Loading branch information
Showing
12 changed files
with
102 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 58 additions & 4 deletions
62
devtools/maven/src/main/java/io/quarkus/maven/components/Prompter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,72 @@ | ||
package io.quarkus.maven.components; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
import org.codehaus.plexus.component.annotations.Component; | ||
import org.aesh.readline.Readline; | ||
import org.aesh.readline.ReadlineBuilder; | ||
import org.aesh.readline.tty.terminal.TerminalConnection; | ||
|
||
/** | ||
* Prompt implementation. | ||
* | ||
* @author <a href="http://escoffier.me">Clement Escoffier</a> | ||
*/ | ||
@Component(role = Prompter.class, instantiationStrategy = "per-lookup") | ||
public class Prompter extends io.quarkus.devtools.utils.Prompter { | ||
public class Prompter { | ||
|
||
private static class Prompt { | ||
private final String prompt; | ||
private final String defaultValue; | ||
private final Consumer<String> inputConsumer; | ||
|
||
public Prompt(String prompt, String defaultValue, Consumer<String> inputConsumer) { | ||
this.prompt = prompt; | ||
this.defaultValue = defaultValue; | ||
this.inputConsumer = inputConsumer; | ||
} | ||
} | ||
|
||
private final List<Prompt> prompts = new ArrayList<>(); | ||
|
||
public Prompter() throws IOException { | ||
super(); | ||
} | ||
|
||
public Prompter addPrompt(String prompt, Consumer<String> inputConsumer) { | ||
prompts.add(new Prompt(prompt, null, inputConsumer)); | ||
return this; | ||
} | ||
|
||
public Prompter addPrompt(String prompt, String defaultValue, Consumer<String> inputConsumer) { | ||
prompts.add(new Prompt(prompt, defaultValue, inputConsumer)); | ||
return this; | ||
} | ||
|
||
public void collectInput() throws IOException { | ||
if (prompts.isEmpty()) { | ||
return; | ||
} | ||
final TerminalConnection connection = new TerminalConnection(); | ||
try { | ||
read(connection, ReadlineBuilder.builder().enableHistory(false).build(), prompts.iterator()); | ||
connection.openBlocking(); | ||
} finally { | ||
connection.close(); | ||
} | ||
} | ||
|
||
private static void read(TerminalConnection connection, Readline readline, Iterator<Prompt> prompts) { | ||
final Prompt prompt = prompts.next(); | ||
readline.readline(connection, prompt.prompt, input -> { | ||
prompt.inputConsumer.accept( | ||
(input == null || input.isBlank()) && prompt.defaultValue != null ? prompt.defaultValue : input); | ||
if (!prompts.hasNext()) { | ||
connection.close(); | ||
} else { | ||
read(connection, readline, prompts); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 0 additions & 57 deletions
57
...dent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/utils/Prompter.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters