/// <summary> /// Start a program and get notified of lines in realtime through <paramref name="lineHandler"/> unlike <see cref="Start(string,string[])"/> /// This won't capture all lines on the returned object and won't default to writing to the Console. /// </summary> /// <param name="timeout">The maximum runtime of the started program</param> /// <param name="lineHandler"> /// An implementation of <see cref="IConsoleLineHandler"/> that receives every line as <see cref="LineOut"/> or the <see cref="Exception"/> that occurs while running /// </param> /// <returns>The exit code and whether the process completed</returns> public static ProcessResult StartRedirected(StartArguments arguments, TimeSpan timeout, IConsoleLineHandler lineHandler = null) => StartRedirected(arguments, timeout, started: null, lineHandler: lineHandler);
public ObservableProcess(StartArguments startArguments) : base(startArguments) { }
protected ObservableProcessBase(StartArguments startArguments) { StartArguments = startArguments ?? throw new ArgumentNullException(nameof(startArguments)); Process = CreateProcess(); CreateObservable(); }
/// <summary> Starts a program and captures the output while writing to the console in realtime during execution </summary> /// <param name="timeout">The maximum runtime of the started program</param> /// <param name="consoleOutWriter"> /// An implementation of <see cref="IConsoleOutWriter"/> that takes care of writing to the console /// <para>defaults to <see cref="ConsoleOutColorWriter"/> which writes standard error messages in red</para> /// </param> /// <returns>An object holding a list of console out lines, the exit code and whether the process completed</returns> public static ProcessCaptureResult Start(StartArguments arguments, TimeSpan timeout, IConsoleOutWriter consoleOutWriter) => Start(arguments, timeout, consoleOutWriter, null);
/// <summary> Starts a program and captures the output while writing to the console in realtime during execution </summary> /// <param name="timeout">The maximum runtime of the started program</param> /// <returns>An object holding a list of console out lines, the exit code and whether the process completed</returns> public static ProcessCaptureResult Start(StartArguments arguments, TimeSpan timeout) => Start(arguments, timeout, null);
/// <summary> Starts a program and captures the output while writing to the console in realtime during execution </summary> /// <returns>An object holding a list of console out lines, the exit code and whether the process completed</returns> public static ProcessCaptureResult Start(StartArguments arguments) => Start(arguments, DefaultTimeout);