openInEditor function
Implementation
Future<void> openInEditor(String editor, String path) async {
String command;
switch (editor) {
case 'code':
command = 'code';
case 'antigravity':
command = 'antigravity';
default:
command = 'code';
}
try {
stdout.writeln(gray(' 🚀 Opening in $editor...'));
final result = await Process.run(command, [path]);
if (result.exitCode != 0) {
stderr.writeln(red(' ✘ Failed to open $editor (exit ${result.exitCode})'));
if (editor == 'code') {
stderr.writeln(gray(' Make sure the "code" command is in your PATH.'));
}
}
} catch (e) {
stderr.writeln(red(' ✘ Error launching $editor: $e'));
}
}