UNPKG

plazbot-cli

Version:
95 lines (80 loc) 3.35 kB
import chalk from 'chalk'; import { getStoredCredentials } from './credentials'; const VERSION = '0.2.0'; // ASCII art del logo Plazbot (burbujas de chat) const logo = [ ' ╭──────────╮ ', ' │ ● ● ● │ ', ' ╰────┬─────╯ ', ' ╭─────┴────────╮ ', ' │ ╭─╮ ╭─╮ │ ', ' │ ╰─╯ ╰─╯ │ ', ' │ ╰────╯ │ ', ' ╰───────────────╯ ', ]; const coloredLogo = logo.map(line => chalk.hex('#2E8B57')(line) ); export async function showBanner(): Promise<void> { const width = 70; // Intentar cargar credenciales let credentials: { email?: string; workspace?: string; zone?: string } | null = null; try { credentials = await getStoredCredentials(); } catch { // No hay credenciales guardadas } console.log(); console.log(chalk.hex('#4CAF50')('─'.repeat(width))); console.log(); // Layout de 2 columnas const leftWidth = 30; const rightStart = leftWidth + 4; // Línea del título const title = chalk.bold.hex('#4CAF50')(` Plazbot CLI v${VERSION}`); // Info columna derecha const rightColumn: string[] = []; if (credentials) { rightColumn.push(chalk.bold.hex('#4CAF50')('Workspace conectado')); rightColumn.push(chalk.gray(` ${credentials.workspace || 'N/A'}`)); rightColumn.push(chalk.gray(` ${credentials.email || ''}`)); rightColumn.push(chalk.gray(` Zona: ${credentials.zone || 'N/A'}`)); rightColumn.push(''); rightColumn.push(chalk.hex('#4CAF50')('─'.repeat(35))); rightColumn.push(''); rightColumn.push(chalk.bold.hex('#4CAF50')('Comandos rapidos')); rightColumn.push(chalk.white(' plazbot agent list')); rightColumn.push(chalk.white(' plazbot agent create')); rightColumn.push(chalk.white(' plazbot agent chat -a <id>')); rightColumn.push(chalk.white(' plazbot whatsapp send-message')); } else { rightColumn.push(chalk.bold.hex('#FFA726')('No conectado')); rightColumn.push(''); rightColumn.push(chalk.bold.hex('#4CAF50')('Para comenzar')); rightColumn.push(chalk.white(' plazbot init -e <email> -k <key> -w <workspace> -z <zone>')); rightColumn.push(''); rightColumn.push(chalk.hex('#4CAF50')('─'.repeat(35))); rightColumn.push(''); rightColumn.push(chalk.bold.hex('#4CAF50')('Documentacion')); rightColumn.push(chalk.gray(' https://docs.plazbot.com')); } // Imprimir título console.log(title); console.log(); // Imprimir logo + info lado a lado const maxLines = Math.max(coloredLogo.length, rightColumn.length); for (let i = 0; i < maxLines; i++) { const left = i < coloredLogo.length ? coloredLogo[i] : ' '.repeat(leftWidth); const right = i < rightColumn.length ? rightColumn[i] : ''; // Pad left column const paddedLeft = left.replace(/\x1b\[[0-9;]*m/g, ''); const padding = ' '.repeat(Math.max(0, leftWidth - paddedLeft.length)); console.log(`${left}${padding} ${right}`); } console.log(); console.log(chalk.hex('#4CAF50')('─'.repeat(width))); console.log(); } export function showMiniHeader(command: string): void { console.log(chalk.hex('#4CAF50')(`\n Plazbot`) + chalk.gray(` > ${command}\n`)); }