dcat: Concatenate File(s) to Standard Output or File

<1 min read

I've just published the first release of dcat, a cat command-line and library implementation in Dart.

final result = await cat(['path/to/file', 'path/to/otherfile]'],
    File('path/to/outfile').openWrite());
if (result.isFailure) {
  for (final error in result.errors) {
    print('Error: ${error.message}');
  }
}

I looked at Dart years ago but never did anything with it. Now that I am interested in using Flutter, I wanted to give it another try.

One thing that immediately caught my eyes is the ability to write command-line applications. This tutorial covers a small app which displays the contents of any files listed on the command line. I figured that was good starting point to turn into a full fleged app and library.

The goal was to completely emulate the standard cat Unix utility, specifically the GNU cat implementation.

I was also very interested in performance, and pleasantly surprised that, while not quite as efficient as the GNU version, it held its own.

Going from writing mostly in Kotlin to Dart felt like a big step backwards, but in all fairness Dart's verbosity is on par with Java. It just took me a bit to get comfortable with it.

As usual, documentation and source are on GitHub.