"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.OpAddModelCommand = void 0;
const commander_1 = require("commander");
const chalk_1 = __importDefault(require("chalk"));
const OperationExecutor_1 = require("../services/OperationExecutor");
const core_1 = require("@myycontext/core");
exports.OpAddModelCommand = new commander_1.Command("op:add-model")
    .description("Generate a new data model interface")
    .argument("<name>", "model name (PascalCase)")
    .argument("<fields>", "comma-separated field:type pairs (e.g., name:string,age:number)")
    .action(async (name, fields) => {
    const fieldList = fields.split(",").map((f) => {
        const [n, t] = f.trim().split(":");
        return { name: n, type: t || "string", required: true };
    });
    const executor = new OperationExecutor_1.OperationExecutor();
    const op = (0, core_1.createOperation)("add-model", `Create model: ${name}`, {
        name,
        fields: fieldList,
    });
    const result = await executor.execute(op);
    if (result.success) {
        console.log(chalk_1.default.green(`\n  ✓ Created model ${name} at ${result.outputPath}\n`));
    }
    else {
        console.error(chalk_1.default.red(`\n  ✗ Failed: ${result.error}\n`));
        process.exit(1);
    }
});
//# sourceMappingURL=op-add-model.js.map