@podx/cli
Version:
đģ Command-line interface for PODx - Advanced Twitter/X scraping and crypto analysis toolkit
84 lines (70 loc) âĸ 2.19 kB
text/typescript
// 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');
}