Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions solr/core/src/java/org/apache/solr/cli/CLIUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ private CLIUtils() {}

public static String YELLOW = "\u001B[33m";

public static String RESET = "\u001B[0m";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are these codes? I have no clue here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the implication of my question is we need a comment with a URL

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are ANSI terminal codes, a standard way to provide colored terminal output. For some reason Package manager uses colored output 🙈

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we did the last pass of the CLI, this jumped out at me as something to rethink in the future. Maybe as part of the picocli migration we drop this (or double down and embrace it everywhere!).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. I'm also sure there exists a java library for TUI (Terminal User Interface) hanlding, if we want to properlty handle color, user input etc.

But I think perhaps we instead should stick to plain ASCII output as you say... Let's remember to cycle back to this..


private static final long MAX_WAIT_FOR_CORE_LOAD_NANOS =
TimeUnit.NANOSECONDS.convert(1, TimeUnit.MINUTES);

Expand Down
4 changes: 1 addition & 3 deletions solr/core/src/java/org/apache/solr/cli/SolrCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,8 @@ public static void printRed(Object message) {
}

public static void print(String color, Object message) {
String RESET = "\u001B[0m";

if (color != null) {
CLIO.out(color + message + RESET);
CLIO.out(color + message + CLIUtils.RESET);
} else {
CLIO.out(String.valueOf(message));
}
Expand Down
10 changes: 10 additions & 0 deletions solr/core/src/java/org/apache/solr/cli/ToolRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ public abstract class ToolRuntime {

public abstract void println(String message);

/** Print an error message, highlighted in red on terminals. */
public void printError(String message) {
println(CLIUtils.RED + message + CLIUtils.RESET);
}

/** Print a success message, highlighted in green on terminals. */
public void printSuccess(String message) {
println(CLIUtils.GREEN + message + CLIUtils.RESET);
}

/** Invokes {@link System#exit(int)} to force the JVM to immediately quit. */
@SuppressForbidden(reason = "That's the only method in CLI code where we allow to exit the JVM")
public void exit(int status) {
Expand Down
Loading
Loading