cat method

Future<void> cat(
  1. String path, {
  2. LineAction stdout = print,
})

implementation for the cat function.

Implementation

Future<void> cat(String path, {LineAction stdout = print}) async {
  final sourceFile = File(path);

  verbose(() => 'cat:  ${truepath(path)}');

  if (!exists(path)) {
    throw CatException('The file at ${truepath(path)} does not exists');
  }

  await sourceFile
      .openRead()
      .transform(utf8.decoder)
      .transform(const LineSplitter())
      .forEach((line) {
    stdout(line);
  });
}