/**
 * @fileoverview Generate Context Command
 *
 * CLI: morph-spec generate context [feature]
 *
 * Generates CONTEXT.md (project-level) or CONTEXT-{feature}.md (feature-level)
 * with all relevant project data for Claude's consumption.
 *
 * @module generate-context
 */

import { generateContext } from '../../lib/generators/context-generator.js';

/**
 * Generate context files
 * @param {string} projectPath - Root path of the project
 * @param {string} featureName - Optional feature name
 * @returns {Promise<void>}
 */
export async function generateContextCommand(projectPath, featureName = null) {
  console.log('📄 Generating CONTEXT files...\n');

  try {
    const results = await generateContext(projectPath, featureName);

    console.log('✅ Generated:');
    console.log(`   - ${results.projectContext}`);

    if (results.featureContext) {
      console.log(`   - ${results.featureContext}`);
    }

    console.log('\n💡 Use these files to provide full context to Claude Code.');

  } catch (err) {
    console.error('❌ Error generating context:');
    console.error(`   ${err.message}`);
    process.exit(1);
  }
}
