/** * JSON output utilities for CLI commands. * * Provides consistent JSON envelope format for all CLI commands when --json flag is used. * This enables scripting, CI/CD integration, and machine-readable output. */ /** * Success envelope for JSON output. */ export interface JsonSuccess { success: true; data: T; } import type { HelpMeta } from '../utils/cli-help.js'; /** * Error envelope for JSON output. */ export interface JsonError { success: false; error: string; code?: string; suggestions?: string[]; help?: HelpMeta; } /** * Union type for all JSON responses. */ export type JsonEnvelope = JsonSuccess | JsonError; /** * Wrap data in success envelope. * * @param data - The data to wrap * @returns Success envelope with data */ export declare function wrapSuccess(data: T): JsonSuccess; /** * Wrap error in error envelope. * * @param message - Error message * @param options - Optional code and suggestions * @returns Error envelope */ export declare function wrapError(message: string, options?: { code?: string; suggestions?: string[]; help?: HelpMeta; }): JsonError; /** * Output JSON to stdout and exit. * Bypasses Ink rendering entirely for clean JSON output. * * @param envelope - JSON envelope to output * @param exitCode - Exit code (default: 0 for success, 1 for error) */ export declare function outputJson(envelope: JsonEnvelope, exitCode?: number): never; /** * Check if JSON output mode is requested. * Useful for early bailout in command handlers. * * @param options - Command options * @returns True if --json flag is set */ export declare function isJsonMode(options: { json?: boolean; }): boolean; /** * Handle JSON output for a command. * Executes the data getter and outputs JSON, catching errors. * * @param getData - Function that returns data or throws * @param errorCode - Optional error code for failures */ export declare function handleJsonOutput(getData: () => T, errorCode?: string): never; //# sourceMappingURL=json-output.d.ts.map