"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const chalk_1 = __importDefault(require("chalk"));
const profile_manager_1 = require("../../lib/profile-manager");
class ContextCreate extends core_1.Command {
    async run() {
        const { args, flags } = await this.parse(ContextCreate);
        try {
            profile_manager_1.ProfileManager.createProfile(args.name);
            console.log(chalk_1.default.green(`✓ Profile '${args.name}' created`));
            if (flags.switch) {
                profile_manager_1.ProfileManager.setActiveProfile(args.name);
                console.log(chalk_1.default.green(`✓ Switched to profile '${args.name}'`));
            }
            else {
                console.log(chalk_1.default.dim(`  Run 'flui context use ${args.name}' to switch to it`));
            }
        }
        catch (error) {
            this.error(error instanceof Error ? error.message : String(error));
        }
    }
}
ContextCreate.description = 'Create a new profile';
ContextCreate.examples = [
    '<%= config.bin %> <%= command.id %> dev',
    '<%= config.bin %> <%= command.id %> prod --switch',
];
ContextCreate.args = {
    name: core_1.Args.string({
        required: true,
        description: 'Profile name (alphanumeric, hyphens, underscores)',
    }),
};
ContextCreate.flags = {
    switch: core_1.Flags.boolean({
        char: 's',
        description: 'Switch to the new profile after creating it',
        default: false,
    }),
};
exports.default = ContextCreate;
