scaffold method

Future<bool> scaffold({
  1. required String path,
  2. required String content,
  3. bool force = false,
  4. String? successMessage,
})

Create a file with common scaffolding patterns Returns true if the file was created successfully

Implementation

Future<bool> scaffold({
  required String path,
  required String content,
  bool force = false,
  String? successMessage,
}) async {
  final file = File(path);

  // Check if file already exists
  if (await file.exists() && !force) {
    error('$path already exists');
    comment('Use --force to overwrite.');
    return false;
  }

  // Ensure directory exists
  await file.parent.create(recursive: true);

  // Write the file
  await file.writeAsString(content);

  if (successMessage != null) {
    success(successMessage);
  } else {
    success('Created: $path');
  }

  return true;
}