run method

  1. @override
Future<void> run()
override

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>';

    // Execute with script path for proper line tracking
    await bridge.execute(code, scriptPath: scriptPath);
  } catch (e) {
    safePrint('Error executing code: $e');
    rethrow;
  }
}