run function

void run(
  1. List<String> arguments, {
  2. DapperCli cli = const DapperCli(),
})

Runs the Dapper CLI.

A broken pipe on stdout (e.g. dapper -o show . | head) is ignored instead of crashing the process.

Implementation

void run(List<String> arguments, {DapperCli cli = const DapperCli()}) {
  stdout.done.then<void>((_) {}, onError: _ignoreBrokenPipe);
  try {
    final result = cli.run(arguments);
    exitCode = result.code;
  } catch (e, stack) {
    stderr.writeln('Unexpected error: $e');
    if (arguments.contains('-v') || arguments.contains('--verbose')) {
      stderr.writeln(Trace.from(stack).terse);
    }
    exitCode = ExitCode.software.code;
  }
}