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?
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?
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
process → RunnableProcess
Experimental - DO NOT USE
no setter
run → void
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
shell → void
shell Runs the given string as a command in the OS shell.
no setter
sink Sink<List<int>>
Experimental - DO NOT USE
no setter

Methods

append(String line, {String? newline}) → void
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
forEach runs the contents of this String as a command line application.
parser({bool runInShell = false}) → Parser
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
Runs the contents of this String as a command line application.
stream({bool runInShell = false, String? workingDirectory, bool nothrow = false, bool includeStderr = true, bool extensionSearch = true}) Stream<String>
Experimental - allows you to get a stream of the output written by the called process.
toList({bool runInShell = false, int skipLines = 0, bool nothrow = false, String? workingDirectory, bool extensionSearch = true}) List<String>
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
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
Truncates a file by setting its length to zero.
write(String line, {String? newline}) → void
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.

Operators

operator |(String rhs) → Pipe
The classic bash style pipe operator. Allows you to chain multiple processes by piping the output of the left hand process to the input of the right hand process.