delete static method

void delete([
  1. List<String>? commands
])

Deletes all or specific command keywords.

  • If no commands provided, delete everything.
  • If list of commands provided, only delete those files.

Implementation

static void delete([List<String>? commands]) {
  if (commands == null || commands.isEmpty) {
    // No commands provided -> delete everything
    if (dir.existsSync()) {
      dir.deleteSync(recursive: true);
    }
    print('✅ ${green}All generated commands removed$reset');
    return;
  }

  // Delete specific commands
  for (final keyword in commands) {
    final pubCacheFile = File('${pubCacheBinDir.path}/$keyword');
    if (pubCacheFile.existsSync()) {
      pubCacheFile.deleteSync();
    }

    final file = File('${binDir.path}/$keyword.dart');
    if (file.existsSync()) {
      file.deleteSync();
      print('✅ ${green}Removed command: $keyword$reset');
    } else {
      print('⚠️  ${yellow}Command not found: $keyword$reset');
    }
  }
}