run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
void run() async {
// Validate inputs
if (argResults?.rest.isEmpty ?? true) {
_handleError('App name is required');
return;
}
final appsName = (argResults?.rest.first ?? '').snakeCase;
// Validate app exists
final pathApps = PathHelper.getAppsPath(appsName);
if (!exists(pathApps)) {
_handleError('App "$appsName" does not exist');
return;
}
try {
// Remove app directory
_removeAppDirectory(pathApps);
// Update locator file
ConfigHelper.removeAppFromLocator(appsName);
// Update pubspec.yaml
ConfigHelper.removeAppFromPubspec(appsName);
// Format code
await _formatCode();
StatusHelper.success('Successfully removed app "$appsName"');
} catch (e) {
_handleError('Failed to remove app "$appsName": ${e.toString()}');
}
}