// cli/commands/status.ts — planu status <specId> [--set implementing] (SPEC-124)
import { parseArgs } from 'node:util';
import { handleUpdateStatus } from '../../tools/update-status.js';
import { formatToolResult } from '../formatter.js';
import { detectProjectId } from '../project-detector.js';
import { red, green } from '../colors.js';
export const statusCommand = {
    name: 'status',
    description: 'Update the status of a spec',
    usage: 'planu status <specId> --set <status> [--project-id ID]',
    async run(args) {
        const { values, positionals } = parseArgs({
            args,
            options: {
                set: { type: 'string', short: 's' },
                'project-id': { type: 'string' },
                notes: { type: 'string', short: 'n' },
            },
            strict: false,
            allowPositionals: true,
        });
        const specId = positionals[0];
        if (!specId) {
            process.stderr.write(`${red('Error:')} Spec ID is required.\nUsage: ${statusCommand.usage}\n`);
            process.exitCode = 1;
            return;
        }
        const status = values.set;
        if (!status) {
            process.stderr.write(`${red('Error:')} --set <status> is required.\nUsage: ${statusCommand.usage}\n`);
            process.exitCode = 1;
            return;
        }
        const projectId = values['project-id'] ?? detectProjectId();
        const result = await handleUpdateStatus({
            specId,
            projectId,
            status: status,
            reviewNotes: values.notes ?? undefined,
        });
        if (result.isError) {
            process.stderr.write(`${red(formatToolResult(result))}\n`);
            process.exitCode = 1;
            return;
        }
        process.stdout.write(`${green('Status updated!')} ${formatToolResult(result)}\n`);
    },
};
//# sourceMappingURL=status.js.map