lastLine property

String? get lastLine

lastLine runs the contents of this String as a cli process and returns the last line written to stdout or stderr as a String.

DCli performs Glob expansion on command arguments. See run for details.

e.g.

'tail -n 10 /var/log/syslog'.lastLine;

NOTE: the current implementation is not efficient as it reads every line from the file rather than reading from the end backwards.

See forEach to capture output to stdout and stderr interactively toParagraph to concatenating the return lines into a single string. run to run the application without capturing its output start - to run the process fully detached. toList - returns a lines written to stdout and stderr as a list. firstLine - returns just the first line written to stdout. parser - returns a parser with the captured output ready to be interpreted as one of several file types.

Implementation

String? get lastLine {
  String? lastLine;

  forEach((line) => lastLine = line, stderr: (line) => lastLine = line);

  return lastLine;
}