Skip to content

Commit

Permalink
try and remove console colors from all output
Browse files Browse the repository at this point in the history
  • Loading branch information
caesay committed Oct 23, 2024
1 parent 34b7879 commit d099cad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions generator/CSharpReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ static string[] GetCommandsFromHelp(string stdout)
.Where(l => !l.StartsWith(" "))
.Select(l => l.Trim())
.Select(l => l.Substring(0, l.IndexOf(" ")))
.Select(l => Regex.Replace(l, @"[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]", ""))
.ToArray();

//Console.WriteLine("Commands: ");
Expand All @@ -351,7 +350,8 @@ static async Task<string> RunCaptureStdOut(string exePath, string[] args)

Console.WriteLine($"Running: {exePath} {string.Join(" ", args)}");

return await RunCaptureStdOut(psi);
string output = await RunCaptureStdOut(psi);
return Util.RemoveConsoleColors(output);
}

static async Task<string> RunCaptureStdOut(ProcessStartInfo psi)
Expand Down
6 changes: 6 additions & 0 deletions generator/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
using System.Net;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using NuGet.Packaging;

namespace DocGenerator;

internal class Util
{
public static string RemoveConsoleColors(string input)
{
return Regex.Replace(input, @"[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]", "");
}

public static async Task StartShellProcess(string path, string[] arguments, string workDir)
{
var psi = new ProcessStartInfo() {
Expand Down

0 comments on commit d099cad

Please sign in to comment.