Skip to content

Commit

Permalink
style constants
Browse files Browse the repository at this point in the history
  • Loading branch information
snazy committed May 2, 2024
1 parent 668602f commit ac224c8
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ public class NessieCliImpl extends BaseNessieCli implements Callable<Integer> {
public static final String OPTION_DUMB_TERMINAL = "--dumb-terminal";

public static final String HISTORY_FILE_DEFAULT = "~/.nessie/nessie-cli.history";
public static final AttributedStyle STYLE_ERROR_HIGHLIGHT = STYLE_ERROR.italic().bold();
public static final AttributedStyle STYLE_ERROR_DELIGHT = STYLE_ERROR.italic().faint();
public static final AttributedStyle STYLE_ERROR_EMPHASIZE1 = STYLE_ERROR.italic().underline();
public static final AttributedStyle STYLE_ERROR_EMPHASIZE2 =
STYLE_ERROR.bold().italic().underline();

private String prompt;
private String rightPrompt;
Expand Down Expand Up @@ -457,13 +462,13 @@ void handleException(Exception e, CommandSpec commandSpec, String source) {
String stackTrace = sw.toString();
stackTrace = stackTrace.substring(stackTrace.indexOf('\n') + 1);
errMsg
.append(e.toString(), STYLE_ERROR.italic().bold())
.append(e.toString(), STYLE_ERROR_HIGHLIGHT)
.append('\n')
.append(stackTrace, AttributedStyle.DEFAULT.italic().bold());
} else {
errMsg
.append(e.getClass().getSimpleName() + ": ", STYLE_ERROR.italic().faint())
.append(e.getMessage(), STYLE_ERROR.italic().bold());
.append(e.getClass().getSimpleName() + ": ", STYLE_ERROR_DELIGHT)
.append(e.getMessage(), STYLE_ERROR_HIGHLIGHT);
String last = "";
for (Throwable cause = e.getCause(); cause != null; cause = cause.getCause()) {
String m = cause.toString();
Expand Down Expand Up @@ -492,8 +497,7 @@ void handleParseException(String input, ParseException e) {
t.getBeginLine(), t.getBeginColumn(), t.getEndLine(), t.getEndColumn()),
STYLE_ERROR)
.append("\n\nFound: ")
.append(
input.substring(t.getBeginOffset(), t.getEndOffset()), STYLE_ERROR.italic().underline())
.append(input.substring(t.getBeginOffset(), t.getEndOffset()), STYLE_ERROR_EMPHASIZE1)
.append("\nExpected one of the following: ");
boolean first = true;
for (Token.TokenType type : e.getExpectedTokenTypes()) {
Expand All @@ -507,9 +511,7 @@ void handleParseException(String input, ParseException e) {
errMsg
.append("\n\n")
.append(input.substring(0, t.getBeginOffset()))
.append(
input.substring(t.getBeginOffset(), t.getEndOffset()),
STYLE_ERROR.bold().italic().underline())
.append(input.substring(t.getBeginOffset(), t.getEndOffset()), STYLE_ERROR_EMPHASIZE2)
.append(input.substring(t.getEndOffset()))
.append("\n\n");

Expand Down

0 comments on commit ac224c8

Please sign in to comment.