UNPKG

@podx/cli

Version:

đŸ’ģ Command-line interface for PODx - Advanced Twitter/X scraping and crypto analysis toolkit

84 lines (70 loc) â€ĸ 2.19 kB
// CLI color utilities export const colors = { reset: '\x1b[0m', bright: '\x1b[1m', dim: '\x1b[2m', underscore: '\x1b[4m', blink: '\x1b[5m', reverse: '\x1b[7m', hidden: '\x1b[8m', // Foreground colors black: '\x1b[30m', red: '\x1b[31m', green: '\x1b[32m', yellow: '\x1b[33m', blue: '\x1b[34m', magenta: '\x1b[35m', cyan: '\x1b[36m', white: '\x1b[37m', // Background colors bgBlack: '\x1b[40m', bgRed: '\x1b[41m', bgGreen: '\x1b[42m', bgYellow: '\x1b[43m', bgBlue: '\x1b[44m', bgMagenta: '\x1b[45m', bgCyan: '\x1b[46m', bgWhite: '\x1b[47m', }; export function colorize(text: string, color: keyof typeof colors): string { return `${colors[color]}${text}${colors.reset}`; } export function success(text: string): string { return colorize(`✅ ${text}`, 'green'); } export function error(text: string): string { return colorize(`❌ ${text}`, 'red'); } export function warning(text: string): string { return colorize(`âš ī¸ ${text}`, 'yellow'); } export function info(text: string): string { return colorize(`â„šī¸ ${text}`, 'blue'); } export function highlight(text: string): string { return colorize(text, 'cyan'); } export function bold(text: string): string { return `${colors.bright}${text}${colors.reset}`; } export function dim(text: string): string { return `${colors.dim}${text}${colors.reset}`; } export function createBox(title: string, content: string[], width: number = 60): string { const horizontalLine = '─'.repeat(width - 2); const topLine = `┌${horizontalLine}┐`; const bottomLine = `└${horizontalLine}┘`; const titleLine = `│${title.padStart((width + title.length) / 2).padEnd(width - 2)}│`; const emptyLine = `│${' '.repeat(width - 2)}│`; const contentLines = content.map(line => { const truncated = line.length > width - 4 ? line.slice(0, width - 7) + '...' : line; return `│ ${truncated.padEnd(width - 4)} │`; }); return [ topLine, titleLine, emptyLine, ...contentLines, bottomLine ].join('\n'); }