StringAsProcess extension

A set of String extensions that lets you execute the contents of a string as a command line application.

e.g. 'tail /var/log/syslog'.run;

on

Properties

firstLine String?

Available on String, provided by the StringAsProcess extension

firstLine treats the contents of this String as a cli process and returns the first line written to stdout or stderr as a String. Returns null if no lines are returned.
no setter
lastLine String?

Available on String, provided by the StringAsProcess extension

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

Available on String, provided by the StringAsProcess extension

Allows you to execute the contents of a dart string as a command line application. Any output from the command (stderr and stdout) is displayed on the console.
no setter

Methods

append(String line, {String? newline}) → void

Available on String, provided by the StringAsProcess extension

Treat the contents of 'this' String as the name of a file and appends line to the file. If newline is null or isn't passed then the platform end of line characters are appended as defined by Platform().eol. Pass null or an '' to newline to not add a line terminator. /// e.g.
forEach(LineAction stdout, {LineAction stderr = _noOpAction, bool runInShell = false, bool extensionSearch = true}) → void

Available on String, provided by the StringAsProcess extension

forEach runs the contents of this String as a command line application.
parser({bool runInShell = false}) → Parser

Available on String, provided by the StringAsProcess extension

parser runs the contents of this String as a cli command line reading all of the returned data and then passes the read lines to a Parser to be decoded as a specific file type.
start({Progress? progress, bool runInShell = false, bool detached = false, bool terminal = false, bool nothrow = false, bool privileged = false, String? workingDirectory, bool extensionSearch = true}) Progress

Available on String, provided by the StringAsProcess extension

Runs the contents of this String as a command line application.
toList({bool runInShell = false, int skipLines = 0, bool nothrow = false, String? workingDirectory, bool extensionSearch = true}) List<String>

Available on String, provided by the StringAsProcess extension

toList runs the contents of this String as a cli command and returns any output written to stdout and stderr as a List<String>.
toParagraph({bool runInShell = false, int skipLines = 0, bool nothrow = false, String? workingDirectory, bool extensionSearch = true}) String

Available on String, provided by the StringAsProcess extension

toParagraph runs the contents of this String as a CLI command and returns the lines written to stdout and stderr as a single String by join the lines with the platform specific line delimiter.
truncate() → void

Available on String, provided by the StringAsProcess extension

Truncates a file by setting its length to zero.
write(String line, {String? newline}) → void

Available on String, provided by the StringAsProcess extension

Truncates and Writes line to the file terminated by newline. If newline is null or isn't passed then the platform end of line characters are appended as defined by Platform().eol. Pass null or an '' to newline to not add a line terminator./// e.g.