/** * `workflow validate` — Validate a workflow definition without executing. * * Loads the workflow, runs schema validation, and reports any errors. * * @example * workflow validate deploy * workflow validate deploy --json */ import type { CliOptions } from '../utils.js'; import { printJson } from '../utils.js'; // --------------------------------------------------------------------------- // Stub: engine integration (not implemented yet) // --------------------------------------------------------------------------- interface ValidationError { path: string; message: string; } interface ValidateResult { valid: boolean; errors: ValidationError[]; workflowName: string; } async function validateWorkflow( _name: string, _cwd?: string, ): Promise { throw new Error('not implemented yet: validateWorkflow'); } // --------------------------------------------------------------------------- // Command handler // --------------------------------------------------------------------------- export async function validateCommand( args: string[], options: CliOptions, ): Promise { if (args.length === 0) { throw new Error('Missing required argument: \n\nUsage: workflow validate [--json]'); } const workflowName = args[0]!; const result = await validateWorkflow(workflowName, options.cwd); if (options.json) { printJson(result); return; } if (result.valid) { console.log(`✓ Workflow "${result.workflowName}" is valid.`); } else { console.log(`✗ Workflow "${result.workflowName}" has ${result.errors.length} error(s):`); console.log(''); for (const err of result.errors) { console.log(` ${err.path}: ${err.message}`); } } }