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
-
Experiemental - DO NOT USE
no setter
- run → void
-
Allows you to execute the contents of a dart string as a
command line appliation.
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
-
Experiemental - DO NOT USE
no setter
Methods
-
append(
String line, {String newline = '\n'}) → void -
Treat the contents of this String as the name of a file
and append
line
to the file.newline
specifies the line termination character. If you don't want a newline appended then pass an empty string tonewline
.newline
defaults to '\n'. -
forEach(
LineAction stdout, {LineAction stderr = _noOpAction, bool runInShell = false}) → 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}) → void - Runs the contents of this String as a command line application.
-
stream(
{bool runInShell = false, String? workingDirectory, bool nothrow = false, bool includeStderr = true}) → Stream< String> - Experiemental - allows you to get a stream of the output written by the called process.
-
toList(
{bool runInShell = false, int skipLines = 0, bool nothrow = false}) → 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>.
-
truncate(
) → void - Truncates a file by setting its length to zero.
-
write(
String line, {String newline = '\n'}) → void -
Truncates and Writes
line
to the file terminated bynewline
.newline
defaults to '\n'.
Operators
-
operator |(
String rhs) → Pipe - The classic bash style pipe operator. Allows you to chain mulitple processes by piping the output of the left hand process to the input of the right hand process.