start method
Runs the contents of this String as a command line application.
Any output from the command (stderr and stdout) is displayed on the console.
DCli performs Glob expansion on command arguments. See run for details.
Use runInShell
if the command needs to be run inside
an OS shell (e.g bash).
runInShell
defaults to false.
Use detached
to start the application as a fully
detached subprocess.
You cannot process output from a detached process and it will continuing running after the dcli process exits. The detached process is also detached from the console and as such no output from the process will be visible.
Use terminal
= true when you need the process attached to a terminal.
When attached to a terminal you will not be able to process
any of the output from the child process.
(e.g. forEach won't work.)
You need to set terminal
=true if you want the called application
to be able to interact with the user (ask for input) or if you
want the application to be able to output ansi codes such
as colours and cursor movement or detect the window size.
You can NOT use terminal
and detached
at the same time.
Use workingDirectory
to specify the directory the process should
be run from.
If you need to run a command with escalated privileged then set the
privileged
argument to true. On Linux this equates to using the sudo command.
The advantage of using the 'privileged' option is that it will first
check if you are
already running in a privileged environment. This is extremely useful
if you
are running in the likes of a Docker container that doesn't implement
sudo but
in which you are already running as root.
Any environment variables you set via env'xxx'
will be passed to the
new process.
If you need to pass an argument to your application that contains spaces then use nested quotes: e.g.
'wc "fred nurk.text"'.start(terminal: true);
See run if you just need to run a process with all the defaults. 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. 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
Progress start({
Progress? progress,
bool runInShell = false,
bool detached = false,
bool terminal = false,
bool nothrow = false,
bool privileged = false,
String? workingDirectory,
bool extensionSearch = true,
}) =>
cmd.start(
this,
progress: progress ?? Progress(print, stderr: printerr),
runInShell: runInShell,
detached: detached,
terminal: terminal,
nothrow: nothrow,
privileged: privileged,
workingDirectory: workingDirectory,
extensionSearch: extensionSearch,
);