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 stdin
    setupArgTable(
      originalArgs: originalArgs,
      scriptPath: '', // Empty for stdin
      scriptArgs: scriptArgs,
    );

    // Read from stdin
    final lines = <String>[];
    await for (final line
        in stdin.transform(utf8.decoder).transform(LineSplitter())) {
      lines.add(line);
    }
    final code = lines.join('\n');
    await bridge.execute(code);
  } catch (e) {
    safePrint('Error executing stdin: $e');
    rethrow;
  }
}