run method

  1. @override
Future<int> run(
  1. List<String> arguments
)
override

Run the command with the given arguments

Implementation

@override
Future<int> run(List<String> arguments) async {
  final args = parseArgs(arguments);

  if (!isInProject()) {
    printError(
        'Not in a Dart/Flutter project directory. Make sure pubspec.yaml exists.');
    return 1;
  }

  final projectDir = getProjectDirectory();
  final claudeFile = File(path.join(projectDir, 'CLAUDE.md'));

  // Check if CLAUDE.md already exists
  if (claudeFile.existsSync() && !(args['force'] as bool)) {
    printError('CLAUDE.md already exists. Use --force to overwrite.');
    return 1;
  }

  // Get toolkit installation path
  final toolkitPath = await _getToolkitPath();
  if (toolkitPath == null) {
    printError('Could not find Claude Dart/Flutter Toolkit installation');
    return 1;
  }

  // Start interactive configuration
  ToolkitLogger.showBanner();
  ToolkitLogger.info('Let\'s configure Claude for your project!\n');

  // Detect and confirm project type
  final detectedProjectType = _detectProjectType(projectDir);
  ToolkitLogger.info('📂 Auto-detected project type: $detectedProjectType\n');

  final projectTypeOptions = ['yes', 'flutter', 'dart', 'package', 'plugin'];
  final projectTypeIndex = await _promptChoice(
    'Is this correct?',
    projectTypeOptions,
    defaultChoice: 'yes',
  );

  final projectTypeChoice = projectTypeOptions[projectTypeIndex];
  final finalProjectType =
      projectTypeChoice == 'yes' ? detectedProjectType : projectTypeChoice;

  ToolkitLogger.info('');
  final projectDescription = Input(
    prompt:
        'Briefly describe what this project does (e.g., "A FinTech app for cross-border payments"):',
  ).interact();

  // Interactive configuration
  final config =
      await _runInteractiveSetup(finalProjectType, projectDescription);

  // Generate tailored CLAUDE.md
  final content = _generateTailoredClaudeConfig(config, toolkitPath);

  // Write CLAUDE.md file
  final spinner =
      ToolkitLogger.spinner('Generating CLAUDE.md configuration...');
  await claudeFile.writeAsString(content);
  spinner.complete();

  ToolkitLogger.boxSummary('Configuration Summary', [
    'Project Type: ${config.type}',
    'Usage: ${_usageTypeDescription(config.usageType)}',
    'Project Size: ${config.size.name}',
    'Focus Areas: ${config.focusAreas.join(', ')}',
  ]);

  ToolkitLogger.info('💡 You can now ask Claude things like:');
  _printUsageExamples(config);

  return 0;
}