Skip to content

Commit

Permalink
Merge pull request quarkusio#18913 from phillip-kruger/newline-on-enter
Browse files Browse the repository at this point in the history
Add new line on enter back
  • Loading branch information
stuartwdouglas authored Jul 21, 2021
2 parents e7e74b8 + cf3d90d commit 9670e47
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ void installBuiltins(DevModeType devModeType) {
? toLevel(((LogManager) LogManager.getLogManager()).getLogger("").getLevel()).toString()
: currentLevel.toString())),
ConsoleStateManager.this::toggleLogLevel));
commands.add(new ConsoleCommand((char) 13, null, null, 10001, null, this::printBlankLine));
commands.add(new ConsoleCommand('h', "Shows this help", "for more options", 10000, null, this::printHelp));
commands.add(new ConsoleCommand('q', "Quits the application", null, this::exitQuarkus));
context.reset(commands.toArray(new ConsoleCommand[0]));
Expand Down Expand Up @@ -175,6 +176,10 @@ public void run() {
}
}

private void printBlankLine() {
System.out.println("");
}

private void printHelp() {
System.out.println("\nThe following commands are currently available:");
Set<ConsoleContext> contexts = new HashSet<>();
Expand All @@ -186,13 +191,15 @@ private void printHelp() {
.collect(Collectors.toList())) {
System.out.println("\n" + RED + "==" + RESET + " " + UNDERLINE + ctx.name + NO_UNDERLINE + "\n");
for (var i : ctx.internal) {
if (i.getHelpState() == null) {
System.out.println(helpOption(i.getKey(), i.getDescription()));
} else if (i.getHelpState().toggleState != null) {
System.out.println(helpOption(i.getKey(), i.getDescription(), i.getHelpState().toggleState.get()));
} else {
System.out.println(helpOption(i.getKey(), i.getDescription(), i.getHelpState().stateSupplier.get(),
i.getHelpState().colorSupplier.get()));
if (i.getDescription() != null) {
if (i.getHelpState() == null) {
System.out.println(helpOption(i.getKey(), i.getDescription()));
} else if (i.getHelpState().toggleState != null) {
System.out.println(helpOption(i.getKey(), i.getDescription(), i.getHelpState().toggleState.get()));
} else {
System.out.println(helpOption(i.getKey(), i.getDescription(), i.getHelpState().stateSupplier.get(),
i.getHelpState().colorSupplier.get()));
}
}
}
}
Expand Down

0 comments on commit 9670e47

Please sign in to comment.