run property
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.
'zip regions.txt regions.zip'.run;
If you need to pass an argument to your application that contains spaces then use nested quotes: e.g.
'wc "fred nurk.text"'.run;
Any environment variables you set via env'xxx'
will be passed
to the new process.
Linux:
DCli performs glob (wildcard) expansion on command arguments
if it contains any one
of *, [ or ?
unless the argument is quoted.
DCli uses the dart package Glob (https://pub.dev/packages/glob) to do the glob expansion.
The following command will have the argument containing the wild card *.dart expanded to the list of files, in the current directory, that match the pattern *.dart.
If no files match the pattern then the pattern will be passed to the command unchanged:
'ls *.dart'.run;
If you add quotes around the wild card then it will not be expanded:
'find . -name "*.dart"'.run;
Windows: On windows Glob expansion is suppressed as both Command and Powershell don't expand globs.
See forEach to capture output to stdout and stderr toList to capture stdout and stderr to List<String> toParagraph to concatenating the return lines into a single string. start - for more control over how the sub process is started. firstLine - returns just the first line written to stdout or stderr. lastLine - returns just the last line written to stdout or stderr. parser - returns a parser with the captured output ready to be interpreted as one of several file types.
Implementation
void get run {
cmd.start(
this,
terminal: true,
progress: Progress(print, stderr: printerr),
);
}