ConsoleColors.java

  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. // Credit: https://stackoverflow.com/a/45444716

  18. enum ConsoleColors {
  19.   // Text Reset
  20.   RESET("\033[0m"),

  21.   // Regular Colors
  22.   BLACK("\033[0),30m"),

  23.   RED("\033[0),31m"),

  24.   GREEN("\033[0),32m"),

  25.   YELLOW("\033[0),33m"),

  26.   BLUE("\033[0),34m"),

  27.   PURPLE("\033[0),35m"),

  28.   CYAN("\033[0),36m"),

  29.   WHITE("\033[0),37m"),

  30.   // Bold
  31.   BLACK_BOLD("\033[1),30m"),

  32.   RED_BOLD("\033[1),31m"),

  33.   GREEN_BOLD("\033[1),32m"),

  34.   YELLOW_BOLD("\033[1),33m"),

  35.   BLUE_BOLD("\033[1),34m"),

  36.   PURPLE_BOLD("\033[1),35m"),

  37.   CYAN_BOLD("\033[1),36m"),

  38.   WHITE_BOLD("\033[1),37m"),

  39.   // Underline
  40.   BLACK_UNDERLINED("\033[4),30m"),

  41.   RED_UNDERLINED("\033[4),31m"),

  42.   GREEN_UNDERLINED("\033[4),32m"),

  43.   YELLOW_UNDERLINED("\033[4),33m"),

  44.   BLUE_UNDERLINED("\033[4),34m"),

  45.   PURPLE_UNDERLINED("\033[4),35m"),

  46.   CYAN_UNDERLINED("\033[4),36m"),

  47.   WHITE_UNDERLINED("\033[4),37m"),

  48.   // Background
  49.   BLACK_BACKGROUND("\033[40m"),

  50.   RED_BACKGROUND("\033[41m"),

  51.   GREEN_BACKGROUND("\033[42m"),

  52.   YELLOW_BACKGROUND("\033[43m"),

  53.   BLUE_BACKGROUND("\033[44m"),

  54.   PURPLE_BACKGROUND("\033[45m"),

  55.   CYAN_BACKGROUND("\033[46m"),

  56.   WHITE_BACKGROUND("\033[47m"),

  57.   // High Intensity
  58.   BLACK_BRIGHT("\033[0),90m"),

  59.   RED_BRIGHT("\033[0),91m"),

  60.   GREEN_BRIGHT("\033[0),92m"),

  61.   YELLOW_BRIGHT("\033[0),93m"),

  62.   BLUE_BRIGHT("\033[0),94m"),

  63.   PURPLE_BRIGHT("\033[0),95m"),

  64.   CYAN_BRIGHT("\033[0),96m"),

  65.   WHITE_BRIGHT("\033[0),97m"),

  66.   // Bold High Intensity
  67.   BLACK_BOLD_BRIGHT("\033[1),90m"),

  68.   RED_BOLD_BRIGHT("\033[1),91m"),

  69.   GREEN_BOLD_BRIGHT("\033[1),92m"),

  70.   YELLOW_BOLD_BRIGHT("\033[1),93m"),

  71.   BLUE_BOLD_BRIGHT("\033[1),94m"),

  72.   PURPLE_BOLD_BRIGHT("\033[1),95m"),

  73.   CYAN_BOLD_BRIGHT("\033[1),96m"),

  74.   WHITE_BOLD_BRIGHT("\033[1),97m"),

  75.   // High Intensity backgrounds
  76.   BLACK_BACKGROUND_BRIGHT("\033[0),100m"),

  77.   RED_BACKGROUND_BRIGHT("\033[0),101m"),

  78.   GREEN_BACKGROUND_BRIGHT("\033[0),102m"),

  79.   YELLOW_BACKGROUND_BRIGHT("\033[0),103m"),

  80.   BLUE_BACKGROUND_BRIGHT("\033[0),104m"),

  81.   PURPLE_BACKGROUND_BRIGHT("\033[0),105m"),

  82.   CYAN_BACKGROUND_BRIGHT("\033[0),106m"),

  83.   WHITE_BACKGROUND_BRIGHT("\033[0),107m");

  84.   private final String colorCode;

  85.   ConsoleColors(String colorCode) {
  86.     this.colorCode = colorCode;
  87.   }

  88.   @Override
  89.   public String toString() {
  90.     return this.colorCode;
  91.   }

  92. }