Skip to content

Commit

Permalink
more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
caesay committed Oct 23, 2024
1 parent 1dd8c20 commit c21a354
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion generator/CSharpReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ static async Task<VpkCommand> GetVpkHelpForDirective(string directive, string vp
{
var help = await RunCaptureStdOut("dotnet", [vpkDll, directive, "-h"]);
var root = new VpkCommand("", help);

await RecursivelyPopulateSubCommands(root, [vpkDll, directive]);
return root;
}
Expand Down Expand Up @@ -308,17 +309,32 @@ public VpkCommand(string name, string helpText)

static string[] GetCommandsFromHelp(string stdout)
{
Console.WriteLine("Trying to determine sub commands from output:");
Console.WriteLine(stdout);

var commandsIdx = stdout.IndexOf("Commands:");
if (commandsIdx == -1) return [];
var commandsText = stdout.Substring(commandsIdx);

var lines = commandsText.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);

return lines.Skip(1)
Console.WriteLine("Lines: ");
foreach (var line in lines) {
Console.WriteLine(" - " + line);
}

var commands = lines.Skip(1)
.Where(l => !l.StartsWith(" "))
.Select(l => l.Trim())
.Select(l => l.Substring(0, l.IndexOf(" ")))
.ToArray();

Console.WriteLine("Commands: ");
foreach (var cmd in commands) {
Console.WriteLine(" - " + cmd);
}

return commands;
}

static async Task<string> RunCaptureStdOut(string exePath, string[] args)
Expand Down

0 comments on commit c21a354

Please sign in to comment.