read function

Stream<List<int>> read(
  1. String path
)

A shorthand for opening the file at path as a stream.

With ByteStreamExtensions.operator |, this can be used to pass the contents of a file into a pipeline:

import 'dart:io';

import 'package:cli_script/cli_script.dart';

void main() {
  wrapMain(() async {
    var pipeline = read("names.txt") |
        Script("grep Natalie") |
        Script("wc -l");
    print("There are ${await pipeline.stdout.text} Natalies");
  });
}

Implementation

Stream<List<int>> read(String path) => File(path).openRead();