import type { ValidationResult, ValueValidationResult } from '../utils/validation'; let verboseMode = false; export function setVerbose(enabled: boolean): void { verboseMode = enabled; } export class CliError extends Error { constructor( message: string, readonly code?: string, ) { super(message); this.name = 'CliError'; } } export function fail(message: string, code?: string): never { throw new CliError(message, code); } export function requireForceForBulkDelete(options: { command: string; force?: boolean; dryRun?: boolean }): void { if (!options.dryRun && !options.force) { fail( `${options.command} requires --force to delete data. Preview the affected rows first with --dry-run, then re-run with --force.`, 'FORCE_REQUIRED', ); } } export function assertValid(result: ValidationResult): void { if (!result.valid) { fail(result.error); } } export function requireValue(result: ValueValidationResult): T { if (!result.valid) { fail(result.error); } return result.value; } export function isVerbose(): boolean { return verboseMode || process.env.RSS_DEBUG === '1'; }