run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
Future<void> run() async {
final org = argResults!['org'] as String;
final nameArg = argResults!['name'] as String?;
// Non-interactive path: --name was supplied, run directly without TUI.
if (nameArg != null && nameArg.isNotEmpty) {
final pluginName = nameArg.trim();
if (!RegExp(r'^[a-z][a-z0-9_]*$').hasMatch(pluginName)) {
stderr.writeln('❌ Invalid plugin name "$pluginName". Use only lowercase letters, numbers, and underscores.');
exit(1);
}
final result = InitResult();
await runApp(InitView(
pluginName: pluginName,
org: org,
result: result,
));
if (result.success) {
stdout.writeln(' \x1B[1;32m✨ $pluginName created\x1B[0m');
} else {
exit(1);
}
return;
}
// Interactive path: show the TUI name form.
final result = InitResult();
await runApp(NitrogenInitApp(result: result, initialOrg: org));
if (result.success) {
stdout.writeln(' \x1B[1;32m✨ ${result.pluginName ?? ''} created\x1B[0m');
} else {
exit(1);
}
}