Progress.stream constructor

Progress.stream({
  1. bool includeStdout = true,
  2. bool includeStderr = true,
})

EXPERIMENTAL

Constructs a Progress that provides a stream of all lines written to stdout and stderr.

You can take control over whether both stdout and stderr are included via the named args includeStderr and includeStdout.

By default both are set to true.

Using a stream is one of the few places in dcli that you will need to use a future. If you don't use a Completer as per the following example then the stream will output data as the rest of your script continues to run.

  var progress = Progress.stream();
  'tail /var/log/syslog'.start(
      progress: progress,
      runInShell: true,
  );

  /// Use a Completer with onDone and waitForEx to
  /// have your code wait until the stream is drained.
  var done = Completer<void>();
  progress.stream.listen((event) {
      print('stream: $event');
    }).onDone(() => done.complete());
  waitForEx<void>(done.future);
  print('done');

Implementation

Progress.stream({this.includeStdout = true, this.includeStderr = true}) {
  /// we don't wire the stream but rather allow the user to
  /// obtain the stream directly
}