/** * `workflow reject` — Reject a paused workflow run. * * Sets $REJECTION_REASON with the provided reason string. * * @example * workflow reject abc123 * workflow reject abc123 "Not compliant" --json */ import type { CliOptions } from '../utils.js'; import { printJson } from '../utils.js'; // --------------------------------------------------------------------------- // Stub: engine integration (not implemented yet) // --------------------------------------------------------------------------- interface RejectResult { runId: string; rejected: boolean; reason?: string; message: string; } async function rejectWorkflowRun( _runId: string, _reason?: string, ): Promise { throw new Error('not implemented yet: rejectWorkflowRun'); } // --------------------------------------------------------------------------- // Command handler // --------------------------------------------------------------------------- export async function rejectCommand( args: string[], options: CliOptions, ): Promise { if (args.length === 0) { throw new Error('Missing required argument: \n\nUsage: workflow reject [reason] [--json]'); } const runId = args[0]!; const reason = args.length > 1 ? args.slice(1).join(' ') : undefined; const result = await rejectWorkflowRun(runId, reason); if (options.json) { printJson(result); return; } if (result.rejected) { console.log(`✗ Run ${result.runId} rejected.`); if (result.reason) { console.log(` Reason: ${result.reason}`); } } else { console.log(`Failed to reject run ${result.runId}: ${result.message}`); } }