public static void ReceiveErrorData(this CommandLineInvocationResult result, object sender, DataReceivedEventArgs e) { if (e.Data is null) { return; } result.AddError(e.Data); }
public static IEnumerable <string> GetErrorLines(this CommandLineInvocationResult result) { using (var reader = result.GetErrorReader()) { while (reader.ReadLineIsNotEnd(out var line)) { yield return(line); } } }
public static CommandLineInvocationResult Run(CommandLineInvocation invocation) { var result = new CommandLineInvocationResult(); void ReceiveOutputData(object sender, DataReceivedEventArgs e) { invocation.ReceiveOutputData(sender, e); result.ReceiveOutputData(sender, e); } void ReceiveErrorData(object sender, DataReceivedEventArgs e) { invocation.ReceiveErrorData(sender, e); result.ReceiveErrorData(sender, e); } result.ExitCode = CommandLineInvocationRunner.Run(invocation.Command, invocation.Arguments, ReceiveOutputData, ReceiveErrorData); return(result); }
public static StringReader GetErrorReader(this CommandLineInvocationResult result) { var reader = new StringReader(result.GetErrorText()); return(reader); }
/// <summary> /// Trims the output text (including any ending \r\n from the output). /// </summary> public static string GetOutputTextTrimmed(this CommandLineInvocationResult result) { var output = result.GetOutputText().Trim(); return(output); }