run method
Implementation
Future<void> run(List<String> arguments) async {
if (arguments.isEmpty) {
_welcome();
return;
}
if (arguments.contains('--version') || arguments.contains('-v')) {
Console.log('$name v$version');
return;
}
final cmdName = arguments.first;
final remaining = arguments.skip(1).toList();
final command = _findCommand(cmdName);
if (command == null) {
Console.error('Unknown command: $cmdName');
Console.log('Run "$name --help" for available commands.');
exit(1);
}
final (args, flags) = _parseArgs(remaining);
try {
await command.handler(args, flags);
} on CliException catch (e) {
Console.error(e.message);
exit(e.exitCode);
} catch (e, stack) {
Console.error('Command failed: $e');
Console.debug(stack.toString());
exit(1);
}
}