#!/usr/bin/env node
"use strict";
/**
 * Bangstack CLI
 * Command-line interface for generating code from workflows
 */
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;
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const chalk_1 = __importDefault(require("chalk"));
const generate_1 = require("./commands/generate");
const validate_1 = require("./commands/validate");
const verify_1 = require("./commands/verify");
const list_generators_1 = require("./commands/list-generators");
const init_1 = require("./commands/init");
const create_workflow_1 = require("./commands/create-workflow");
const commit_1 = require("./commands/commit");
const log_1 = require("./commands/log");
const show_1 = require("./commands/show");
const version_commands_1 = require("./version-commands");
const packageJson = __importStar(require("../../package.json"));
const program = new commander_1.Command();
program
    .name('bangstack')
    .description('Generate production-ready code from workflow definitions')
    .version(packageJson.version);
// Generate command
program
    .command('generate <workflow>')
    .description('Generate code from a workflow file')
    .option('-o, --output <directory>', 'Output directory for generated code (supports relative or absolute paths)', '.')
    .option('-d, --dry-run', 'Show what would be generated without writing files', false)
    .option('-v, --verbose', 'Show detailed output', false)
    .option('-r, --resume', 'Resume from last checkpoint after failure', false)
    .option('--no-checkpoint', 'Disable checkpoint system', false)
    .option('--no-retry', 'Disable automatic retry for transient failures', false)
    .option('--max-retries <number>', 'Maximum retry attempts', parseInt, 3)
    .action(generate_1.generateCommand);
// Validate command
program
    .command('validate <workflow>')
    .description('Validate a workflow file')
    .option('-d, --directory', 'Validate all workflow files in a directory', false)
    .action(validate_1.validateCommand);
// Verify command
program
    .command('verify <workflow>')
    .description('Verify workflow and check for dependency mismatches')
    .option('-o, --output <directory>', 'Output directory to check against', process.cwd())
    .option('-v, --verbose', 'Show detailed output', false)
    .action(verify_1.verifyCommand);
// List generators command
program
    .command('list-generators')
    .alias('list')
    .description('List all available code generators')
    .option('-v, --verbose', 'Show detailed information about each generator', false)
    .option('-c, --category <category>', 'Filter by category (frontend, backend, database, test, documentation)')
    .action(list_generators_1.listGeneratorsCommand);
// Init command
program
    .command('init [project-name]')
    .description('Initialize a new project with optional preset')
    .option('-p, --preset <preset>', 'Use a preset stack (mern, next-trpc, django-react, etc.)')
    .option('--example', 'Create with example workflow', false)
    .action(init_1.initCommand);
// Create workflow command
program
    .command('create')
    .alias('new')
    .description('Create a new workflow interactively')
    .action(create_workflow_1.createWorkflowCommand);
// Commit command
program
    .command('commit')
    .description('Create a commit of config.yaml changes')
    .option('-m, --message <message>', 'Commit message')
    .option('-a, --author <author>', 'Commit author (defaults to git config)')
    .action(commit_1.commitCommand);
// Log command
program
    .command('log')
    .description('Show commit history')
    .option('-n, --limit <number>', 'Limit number of commits to show', parseInt)
    .option('--oneline', 'Show one commit per line', false)
    .action(log_1.logCommand);
// Show command
program
    .command('show <hash>')
    .description('Show details of a specific commit')
    .option('--stat', 'Show only statistics, not full diff', false)
    .action(show_1.showCommand);
// Register version commands
(0, version_commands_1.registerVersionCommands)(program);
// Custom help display
program.on('--help', () => {
    console.log('');
    console.log('Examples:');
    console.log('  $ bang create                                    # Interactive workflow creation');
    console.log('  $ bang init my-app --preset mern                # Initialize with MERN preset');
    console.log('  $ bang generate workflow.yaml --output ./app    # Generate code');
    console.log('  $ bang validate workflow.yaml                   # Validate workflow');
    console.log('  $ bang list-generators                          # List available generators');
    console.log('');
    console.log('Quick Start:');
    console.log('  1. Create a new project:      bang init my-app');
    console.log('  2. Edit the workflow:         cd my-app && edit workflows/my-app.workflow.yaml');
    console.log('  3. Generate code:             bang generate workflows/my-app.workflow.yaml');
    console.log('');
    console.log('Learn more: https://github.com/mogullabs/bangstack');
});
// Parse arguments
program.parse(process.argv);
// Show enhanced help if no command provided
if (!process.argv.slice(2).length) {
    console.log('');
    console.log(chalk_1.default.cyan.bold('┌─────────────────────────────────────────────────────┐'));
    console.log(chalk_1.default.cyan.bold('│') + '  ' + chalk_1.default.white.bold('Bangstack') + ' - Code Generation from Workflows  ' + chalk_1.default.cyan.bold('│'));
    console.log(chalk_1.default.cyan.bold('└─────────────────────────────────────────────────────┘'));
    console.log('');
    console.log(chalk_1.default.bold('Quick Start Commands:'));
    console.log('  ' + chalk_1.default.cyan('bang create') + '        Create a new workflow interactively');
    console.log('  ' + chalk_1.default.cyan('bang init') + '          Initialize a new project');
    console.log('  ' + chalk_1.default.cyan('bang generate') + '      Generate code from a workflow');
    console.log('  ' + chalk_1.default.cyan('bang list') + '          List available generators');
    console.log('');
    console.log(chalk_1.default.bold('Need help?'));
    console.log('  ' + chalk_1.default.gray('Run') + ' ' + chalk_1.default.cyan('bang --help') + ' ' + chalk_1.default.gray('to see all commands'));
    console.log('  ' + chalk_1.default.gray('Run') + ' ' + chalk_1.default.cyan('bang <command> --help') + ' ' + chalk_1.default.gray('for command-specific help'));
    console.log('');
    console.log(chalk_1.default.gray('Documentation: https://github.com/mogullabs/bangstack'));
    console.log('');
    process.exit(0);
}
//# sourceMappingURL=index.js.map