runExecutableArguments function

Future<ProcessResult> runExecutableArguments(
  1. String executable,
  2. List<String> arguments, {
  3. ShellOptions? options,
  4. String? workingDirectory,
  5. Map<String, String>? environment,
  6. bool includeParentEnvironment = true,
  7. bool? runInShell,
  8. Encoding? stdoutEncoding = systemEncoding,
  9. Encoding? stderrEncoding = systemEncoding,
  10. Stream<List<int>>? stdin,
  11. StreamSink<List<int>>? stdout,
  12. StreamSink<List<int>>? stderr,
  13. bool? verbose,
  14. bool? commandVerbose,
  15. bool? noStdoutResult,
  16. bool? noStderrResult,
  17. ShellOnProcessCallback? onProcess,
  18. ProcessStartMode? mode,
  19. bool? throwOnError,
})

if commandVerbose or verbose is true, display the command. if verbose is true, stream stdout & stdin

Optional onProcess(process) is called to allow killing the process.

If noStdoutResult is true, the result will not contain the stdout. If noStderrResult is true, the result will not contain the stderr.

Don't mess-up with the input and output for now here. only use it for kill.

Implementation

Future<ProcessResult> runExecutableArguments(
  String executable,
  List<String> arguments, {

  /// Prefer options, or even better, use a shell...
  ShellOptions? options,
  // follwing To deprecate
  String? workingDirectory,
  Map<String, String>? environment,
  bool includeParentEnvironment = true,
  bool? runInShell,
  Encoding? stdoutEncoding = systemEncoding,
  Encoding? stderrEncoding = systemEncoding,
  Stream<List<int>>? stdin,
  StreamSink<List<int>>? stdout,
  StreamSink<List<int>>? stderr,
  bool? verbose,
  bool? commandVerbose,
  bool? noStdoutResult,
  bool? noStderrResult,
  ShellOnProcessCallback? onProcess,
  ProcessStartMode? mode,

  /// Compat default to false...
  bool? throwOnError,
}) async {
  throwOnError ??= false;
  options ??= ShellOptions(
    verbose: verbose ?? false,
    commandVerbose: commandVerbose,
    stderrEncoding: stderrEncoding,
    stdoutEncoding: stdoutEncoding,
    workingDirectory: workingDirectory,
    stdout: stdout,
    stderr: stderr,
    stdin: stdin,
    environment: environment,
    includeParentEnvironment: includeParentEnvironment,
    runInShell: runInShell,
    mode: mode,
    noStderrResult: noStderrResult,
    noStdoutResult: noStdoutResult,
    throwOnError: throwOnError,
  );
  var shell = Shell(options: options);
  var result = await shell.runExecutableArguments(
    executable,
    arguments,
    onProcess: onProcess,
  );
  return result;
}