run method
Executes a command based on the provided arguments.
Supported commands:
create: Creates a new Flutter project from a template.icon: Changes the app icon using theflutter_launcher_iconspackage.help/--help/-h: Displays help information.
Throws:
- Exception if an unhandled error occurs during command execution.
Implementation
Future<void> run(List<String> arguments) async {
if (arguments.isEmpty) {
_printHelp();
return;
}
final command = arguments.first;
try {
switch (command) {
case 'create':
await CreateCommand(logger).run(arguments.skip(1).toList());
break;
case 'icon':
await IconCommand(logger).run(arguments.skip(1).toList());
break;
case 'help':
case '--help':
case '-h':
_printHelp();
break;
default:
logger.err('Unknown command: $command');
_printHelp();
}
} catch (e) {
logger.err('Error: $e');
rethrow;
}
}