/**
 * ANSI 转义序列工具
 */

const CLEAR = '\x1B[0m';
const CLEAR_LINE = '\x1B[2K';

// 颜色
const RED = '\x1B[31m';
const GREEN = '\x1B[32m';
const YELLOW = '\x1B[33m';
const BLUE = '\x1B[34m';
const MAGENTA = '\x1B[35m';
const CYAN = '\x1B[36m';
const WHITE = '\x1B[37m';
const DIM = '\x1B[2m';
const BOLD = '\x1B[1m';

/**
 * 创建带颜色的字符串
 */
function colored(text, color) {
  if (!color) return text;
  return `${color}${text}${CLEAR}`;
}

module.exports = {
  CLEAR,
  CLEAR_LINE,
  RED,
  GREEN,
  YELLOW,
  BLUE,
  MAGENTA,
  CYAN,
  WHITE,
  DIM,
  BOLD,
  colored,
};
