"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createCommand = void 0;
const commander_1 = require("commander");
const error_handler_1 = require("../utils/error.handler");
const create_service_1 = require("../services/create.service");
exports.createCommand = new commander_1.Command('create')
    .description('Create a new io.Connect Desktop project')
    .option('--source <url/path>', 'Override component source during setup')
    .option('--non-interactive', 'Run in non-interactive mode using provided options')
    .option('--product-name <name>', 'Product name for non-interactive mode')
    .option('--folder-name <name>', 'Folder name for non-interactive mode')
    .option('--components <components>', 'Comma-separated list of components (e.g., "iocd,demos,devTools")')
    .option('--applications <applications>', 'Comma-separated list of applications (e.g., "groups,workspaces")')
    .option('--license-key <key>', 'License key for non-interactive mode')
    .option('--use-current-folder', 'Install in current folder (non-interactive mode)')
    .action(async (options) => {
    try {
        const setupService = new create_service_1.CreateService();
        if (options.nonInteractive) {
            // Validate required options for non-interactive mode
            if (!options.productName || !options.folderName) {
                throw new Error('Non-interactive mode requires --product-name and --folder-name options');
            }
            await setupService.runNonInteractiveSetup({
                productName: options.productName,
                folderName: options.folderName,
                components: options.components ? options.components.split(',').map((c) => c.trim()) : ['iocd'],
                applications: options.applications ? options.applications.split(',').map((a) => a.trim()) : [],
                licenseKey: options.licenseKey,
                source: options.source,
                useCurrentFolder: options.useCurrentFolder
            });
            process.exit(0);
        }
        else {
            await setupService.runSetup();
        }
    }
    catch (error) {
        error_handler_1.ErrorHandler.handle(error);
    }
});
//# sourceMappingURL=create.command.js.map