delete static method
Deletes all or specific command keywords.
- If no
commandsprovided, delete everything. - If list of
commandsprovided, 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');
}
}
}