/** * GitFlow Output — JSON vs human-readable formatting. * Self-contained: no logger dependency, uses console directly. */ import type { BaseResult } from './types.js'; export function formatResult( result: T, json: boolean, humanFormatter?: (result: T) => void, ): void { if (json) { console.log(JSON.stringify(result, null, 2)); return; } if (humanFormatter) { humanFormatter(result); return; } if (result.success) { console.log('[OK] Operation completed successfully'); } else { console.error(`[ERROR] ${result.error || 'Operation failed'}`); } } export function outputError(error: string, json: boolean): void { formatResult({ success: false, error }, json); } export function outputField(label: string, value: string): void { console.log(` ${label}: ${value}`); } export function outputSection(title: string): void { console.log(); console.log(`## ${title}`); } export function outputActions(actions: Array<{ description: string; command: string; priority: string }>): void { if (actions.length === 0) return; outputSection('Actions'); for (const action of actions) { const icon = action.priority === 'high' ? '!' : action.priority === 'medium' ? '-' : ' '; console.log(` [${icon}] ${action.description}`); console.log(` ${action.command}`); } }