init method

  1. @cliCommand
Future<void> init({
  1. String? type,
  2. bool force = false,
})

Initialize a project-local configuration file

Creates a .claudio.yaml file in the current directory with default settings that can be customized.

Implementation

@cliCommand
Future<void> init({
  /// Project type to use (default: auto-detect)
  String? type,

  /// Overwrite existing configuration
  bool force = false,
}) async {
  final configPath = p.join(Directory.current.path, '.claudio.yaml');
  final configFile = File(configPath);

  if (configFile.existsSync() && !force) {
    warn('Configuration already exists at: $configPath');
    info('Use --force to overwrite');
    return;
  }

  // Auto-detect or use specified project type
  final projectType = type != null
      ? ProjectType.values.firstWhere(
          (t) => t.name == type,
          orElse: () => ProjectType.auto,
        )
      : LanguageConfig.detectProjectType(Directory.current.path);

  final config = GenConfig.withDefaults().copyWith(
    projectTypeName: projectType.name,
  );

  await config.saveToFile(configPath);

  success('Configuration initialized at: $configPath');
  info('Detected project type: ${projectType.name}');
  info('Edit this file to customize your settings');
}