"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.OpAddRouteCommand = 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.OpAddRouteCommand = new commander_1.Command("op:add-route")
    .description("Add a new route page")
    .argument("<path>", "route path (e.g., /dashboard/settings)")
    .argument("<component>", "component name to render")
    .option("--layout <layout>", "layout component")
    .option("--auth", "require authentication", false)
    .action(async (routePath, component, options) => {
    const executor = new OperationExecutor_1.OperationExecutor();
    const op = (0, core_1.createOperation)("add-route", `Add route: ${routePath}`, {
        path: routePath,
        component,
        layout: options.layout,
        auth: options.auth,
    });
    const result = await executor.execute(op);
    if (result.success) {
        console.log(chalk_1.default.green(`\n  ✓ Added route ${routePath} → ${component}\n`));
    }
    else {
        console.error(chalk_1.default.red(`\n  ✗ Failed: ${result.error}\n`));
        process.exit(1);
    }
});
//# sourceMappingURL=op-add-route.js.map