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 {
try {
// Setup arg table for -e mode
setupArgTable(originalArgs: originalArgs, codeStrings: [code]);
// Use a special script path name for code executed via -e
// This allows debug.getinfo to report something meaningful for -e code
const scriptPath = '<command line>';
// Lua chunks must be statements. If the raw code doesn't parse (e.g.
// `-e "1+2"` is an expression, not a statement), wrap with `return`.
final source = _parses(code) ? code : 'return $code';
await bridge.execute(source, scriptPath: scriptPath);
} catch (e) {
safePrint('Error executing code: $e');
rethrow;
}
}