1 package com.jsql.util;
2
3 public class AnsiColorUtil {
4
5 private static final String PREFIX = "\u001b[";
6
7 private static final int NORMAL = 0;
8
9 private static final char SEPARATOR = ';';
10
11 private static final int FOREGROUND_RED = 31;
12 private static final int FOREGROUND_GREEN = 32;
13
14 private static final String SUFFIX = "m";
15
16 private static final String END_COLOUR = PREFIX + SUFFIX;
17
18 private static final String ERROR_COLOUR = PREFIX + NORMAL + SEPARATOR + FOREGROUND_RED + SUFFIX;
19 private static final String INFO_COLOUR = PREFIX + NORMAL+ SEPARATOR + FOREGROUND_GREEN + SUFFIX;
20
21 private AnsiColorUtil() {
22
23 }
24
25 public static String addGreenColor(String text) {
26 return INFO_COLOUR + text + END_COLOUR;
27 }
28
29 public static String addRedColor(String text) {
30 return ERROR_COLOUR + text + END_COLOUR;
31 }
32 }