View Javadoc
1   /*
2    *    Copyright 2010-2023 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.apache.ibatis.migration;
17  
18  // Credit: https://stackoverflow.com/a/45444716
19  
20  enum ConsoleColors {
21    // Text Reset
22    RESET("\033[0m"),
23  
24    // Regular Colors
25    BLACK("\033[0),30m"),
26  
27    RED("\033[0),31m"),
28  
29    GREEN("\033[0),32m"),
30  
31    YELLOW("\033[0),33m"),
32  
33    BLUE("\033[0),34m"),
34  
35    PURPLE("\033[0),35m"),
36  
37    CYAN("\033[0),36m"),
38  
39    WHITE("\033[0),37m"),
40  
41    // Bold
42    BLACK_BOLD("\033[1),30m"),
43  
44    RED_BOLD("\033[1),31m"),
45  
46    GREEN_BOLD("\033[1),32m"),
47  
48    YELLOW_BOLD("\033[1),33m"),
49  
50    BLUE_BOLD("\033[1),34m"),
51  
52    PURPLE_BOLD("\033[1),35m"),
53  
54    CYAN_BOLD("\033[1),36m"),
55  
56    WHITE_BOLD("\033[1),37m"),
57  
58    // Underline
59    BLACK_UNDERLINED("\033[4),30m"),
60  
61    RED_UNDERLINED("\033[4),31m"),
62  
63    GREEN_UNDERLINED("\033[4),32m"),
64  
65    YELLOW_UNDERLINED("\033[4),33m"),
66  
67    BLUE_UNDERLINED("\033[4),34m"),
68  
69    PURPLE_UNDERLINED("\033[4),35m"),
70  
71    CYAN_UNDERLINED("\033[4),36m"),
72  
73    WHITE_UNDERLINED("\033[4),37m"),
74  
75    // Background
76    BLACK_BACKGROUND("\033[40m"),
77  
78    RED_BACKGROUND("\033[41m"),
79  
80    GREEN_BACKGROUND("\033[42m"),
81  
82    YELLOW_BACKGROUND("\033[43m"),
83  
84    BLUE_BACKGROUND("\033[44m"),
85  
86    PURPLE_BACKGROUND("\033[45m"),
87  
88    CYAN_BACKGROUND("\033[46m"),
89  
90    WHITE_BACKGROUND("\033[47m"),
91  
92    // High Intensity
93    BLACK_BRIGHT("\033[0),90m"),
94  
95    RED_BRIGHT("\033[0),91m"),
96  
97    GREEN_BRIGHT("\033[0),92m"),
98  
99    YELLOW_BRIGHT("\033[0),93m"),
100 
101   BLUE_BRIGHT("\033[0),94m"),
102 
103   PURPLE_BRIGHT("\033[0),95m"),
104 
105   CYAN_BRIGHT("\033[0),96m"),
106 
107   WHITE_BRIGHT("\033[0),97m"),
108 
109   // Bold High Intensity
110   BLACK_BOLD_BRIGHT("\033[1),90m"),
111 
112   RED_BOLD_BRIGHT("\033[1),91m"),
113 
114   GREEN_BOLD_BRIGHT("\033[1),92m"),
115 
116   YELLOW_BOLD_BRIGHT("\033[1),93m"),
117 
118   BLUE_BOLD_BRIGHT("\033[1),94m"),
119 
120   PURPLE_BOLD_BRIGHT("\033[1),95m"),
121 
122   CYAN_BOLD_BRIGHT("\033[1),96m"),
123 
124   WHITE_BOLD_BRIGHT("\033[1),97m"),
125 
126   // High Intensity backgrounds
127   BLACK_BACKGROUND_BRIGHT("\033[0),100m"),
128 
129   RED_BACKGROUND_BRIGHT("\033[0),101m"),
130 
131   GREEN_BACKGROUND_BRIGHT("\033[0),102m"),
132 
133   YELLOW_BACKGROUND_BRIGHT("\033[0),103m"),
134 
135   BLUE_BACKGROUND_BRIGHT("\033[0),104m"),
136 
137   PURPLE_BACKGROUND_BRIGHT("\033[0),105m"),
138 
139   CYAN_BACKGROUND_BRIGHT("\033[0),106m"),
140 
141   WHITE_BACKGROUND_BRIGHT("\033[0),107m");
142 
143   private final String colorCode;
144 
145   ConsoleColors(String colorCode) {
146     this.colorCode = colorCode;
147   }
148 
149   @Override
150   public String toString() {
151     return this.colorCode;
152   }
153 
154 }