Skip to content

Commit

Permalink
Colour the console on stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
BlythMeister committed Feb 18, 2020
1 parent a884364 commit 4664cd5
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/PaketChain/ConsoleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,25 @@ void ProcessDataReceived(object sender, DataReceivedEventArgs dataReceivedEventA
output.Add(dataReceivedEventArgs.Data);
}

process.OutputDataReceived += ProcessDataReceived;
process.ErrorDataReceived += ProcessDataReceived;
process.OutputDataReceived += (sender, args) =>
{
if (!silent)
{
Console.WriteLine(args.Data);
}
output.Add(args.Data);
};

process.ErrorDataReceived += (sender, args) =>
{
if (!silent)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(args.Data);
Console.ResetColor();
}
output.Add(args.Data);
};

cancellationToken.Register(() => process.Kill(true));

Expand Down

0 comments on commit 4664cd5

Please sign in to comment.