run method
Implementation
Future<int> run() async {
if (!context.terminal.isInteractive) {
context.logger.warn(
'Interactive mode requires a terminal. Use --include for automation.',
tag: 'CLEAN',
);
return CleanerExitCode.usage.code;
}
final scanPath = _chooseScanDirectory();
context.logger.info('Scanning directory: $scanPath');
while (true) {
_showMenu();
final choice = context.terminal
.prompt('Choose an option:', defaultValue: '0')
.trim();
switch (choice) {
case '1':
await _cleanTargets(
'Cleaning Flutter build folders',
() => _flutterBuildTargets(scanPath),
);
case '2':
await _runFlutterClean(scanPath);
case '3':
await _cleanTargets('Cleaning Gradle cache', _gradleTargets);
case '4':
await _cleanTargets(
'Cleaning CocoaPods',
() => _cocoaPodsTargets(scanPath),
);
case '5':
await _cleanTargets('Cleaning Xcode DerivedData', _xcodeTargets);
case '6':
await _cleanTargets(
'Cleaning Android build cache',
_androidBuildCacheTargets,
);
case '7':
await _runCommand('Cleaning unavailable iOS simulators', [
'xcrun',
'simctl',
'delete',
'unavailable',
]);
case '8':
await _runCommand('Cleaning Homebrew cache', [
'brew',
'cleanup',
'-s',
]);
case '9':
await _cleanTargets('Emptying Trash', _trashTargets);
case '10':
await _cleanTargets('Cleaning temporary files', _temporaryTargets);
case '11':
await _runCommand('Running flutter pub cache gc', [
'flutter',
'pub',
'cache',
'gc',
]);
case '12':
await _fullCleanup(scanPath);
case '13':
await _showLargestFolders(scanPath);
case '14':
_dryRun = !_dryRun;
context.logger.warn(
'Dry run mode ${_dryRun ? 'enabled' : 'disabled'}',
tag: 'CLEAN',
);
case '0':
_showReport();
context.logger.success('Exiting cleaner');
return CleanerExitCode.success.code;
default:
context.logger.err('Invalid option');
}
}
}