file_tailer 1.0.0 file_tailer: ^1.0.0 copied to clipboard
Watch for file changes
import 'dart:convert' show LineSplitter, utf8;
import 'dart:io' show File, stderr, stdout;
import 'package:file_tailer/file_tailer.dart' show tailFile;
void main(List<String> arguments) {
if (arguments.length != 1) {
stderr.write('You need to provide exactly one file to be tailed.\n');
return 1;
}
final (stream, _) = tailFile(File(arguments.first));
stream
.transform(utf8.decoder)
.transform(const LineSplitter())
.forEach((line) async => stdout.write('$line\n'));
}