"use strict";
/**
 * List generators command
 * Lists all available code generators
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.listGeneratorsCommand = listGeneratorsCommand;
const generator_registry_1 = require("../../generators/generator-registry");
const output = __importStar(require("../output"));
require("../../generators"); // Ensure generators are registered
function listGeneratorsCommand(options = {}) {
    output.banner('Bangstack Generators', 'Available code generators for your workflows');
    output.blank();
    // Filter by category if specified
    const shouldShow = (category) => !options.category || options.category === category;
    // Frontend generators
    const frontendFrameworks = generator_registry_1.globalRegistry.listFrontendFrameworks();
    if (frontendFrameworks.length > 0 && shouldShow('frontend')) {
        output.header('Frontend Frameworks');
        for (const framework of frontendFrameworks) {
            const generator = generator_registry_1.globalRegistry.getFrontendGenerator(framework);
            if (generator) {
                output.success(`${generator.name || framework}`);
                if (generator.description) {
                    console.log(output.dim(`  ${generator.description}`));
                }
                if (options.verbose) {
                    console.log(output.dim(`  Usage in workflow: ${output.code(`stack.frontend.technology: "${framework}"`)}`));
                    if (generator.framework) {
                        console.log(output.dim(`  Framework: ${generator.framework}`));
                    }
                }
                output.blank();
            }
        }
    }
    // Backend generators
    const backendLanguages = generator_registry_1.globalRegistry.listBackendLanguages();
    if (backendLanguages.length > 0 && shouldShow('backend')) {
        output.header('Backend Languages');
        for (const language of backendLanguages) {
            const generator = generator_registry_1.globalRegistry.getBackendGenerator(language);
            if (generator) {
                output.success(`${generator.name || language}`);
                if (generator.description) {
                    console.log(output.dim(`  ${generator.description}`));
                }
                if (options.verbose) {
                    const techString = generator.framework ? `${language}/${generator.framework}` : language;
                    console.log(output.dim(`  Usage in workflow: ${output.code(`stack.backend.technology: "${techString}"`)}`));
                    if (generator.language) {
                        console.log(output.dim(`  Language: ${generator.language}`));
                    }
                    if (generator.framework) {
                        console.log(output.dim(`  Framework: ${generator.framework}`));
                    }
                }
                output.blank();
            }
        }
    }
    // Documentation generators
    const docFormats = generator_registry_1.globalRegistry.listDocumentationFormats();
    if (docFormats.length > 0 && shouldShow('documentation')) {
        output.header('Documentation Formats');
        for (const format of docFormats) {
            const generator = generator_registry_1.globalRegistry.getDocumentationGenerator(format);
            if (generator) {
                output.success(`${generator.name || format}`);
                if (generator.description) {
                    console.log(output.dim(`  ${generator.description}`));
                }
                if (options.verbose && generator.format) {
                    console.log(output.dim(`  Format: ${generator.format}`));
                }
                output.blank();
            }
        }
    }
    // Database generators
    const databases = generator_registry_1.globalRegistry.listDatabases();
    if (databases.length > 0 && shouldShow('database')) {
        output.header('Database Generators');
        for (const db of databases) {
            const generator = generator_registry_1.globalRegistry.getDatabaseGenerator(db);
            if (generator) {
                output.success(`${generator.name || db}`);
                if (generator.description) {
                    console.log(output.dim(`  ${generator.description}`));
                }
                if (options.verbose) {
                    console.log(output.dim(`  Usage in workflow: ${output.code(`stack.database.technology: "${db}"`)}`));
                    if (generator.database) {
                        console.log(output.dim(`  Database: ${generator.database}`));
                    }
                }
                output.blank();
            }
        }
    }
    // Test generators
    const testFrameworks = generator_registry_1.globalRegistry.listTestFrameworks();
    if (testFrameworks.length > 0 && shouldShow('test')) {
        output.header('Testing Frameworks');
        for (const framework of testFrameworks) {
            const generator = generator_registry_1.globalRegistry.getTestGenerator(framework);
            if (generator) {
                output.success(`${generator.name || framework}`);
                if (generator.description) {
                    console.log(output.dim(`  ${generator.description}`));
                }
                if (options.verbose && generator.testFramework) {
                    console.log(output.dim(`  Framework: ${generator.testFramework}`));
                }
                output.blank();
            }
        }
    }
    // Summary
    const total = frontendFrameworks.length +
        backendLanguages.length +
        docFormats.length +
        databases.length +
        testFrameworks.length;
    output.blank();
    output.header('Summary');
    output.table([
        ['Frontend Frameworks', frontendFrameworks.length.toString()],
        ['Backend Languages', backendLanguages.length.toString()],
        ['Documentation Formats', docFormats.length.toString()],
        ['Database Generators', databases.length.toString()],
        ['Testing Frameworks', testFrameworks.length.toString()],
        ['Total', output.bold(total.toString())],
    ]);
    output.blank();
    output.info(`Run ${output.code('bang list-generators --verbose')} for detailed information`);
    output.info(`Run ${output.code('bang list-generators --category <category>')} to filter by category`);
}
//# sourceMappingURL=list-generators.js.map