JasperFx / oakton

Parsing and Utilities for Command Line Tools in .Net
http://jasperfx.github.io/oakton
Apache License 2.0
308 stars 41 forks source link

"describe" command throws exception when configuration values contain "[" #70

Closed kuanpak closed 2 years ago

kuanpak commented 2 years ago

Oakton version: 4.6.1

Error can be reproduced by below code and appsettings.json.

C# code:

using Oakton;

var builder = WebApplication.CreateBuilder(args);
builder.Host.ApplyOaktonExtensions();

var app = builder.Build();

app.MapGet("/", () => "Hello World!");

return await app.RunOaktonCommands(args);

appsettings.json

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "ProblemConfig": "value with [bracket]"
}

When run dotnet run describe, it will throw below exception:

ERROR: System.InvalidOperationException: Could not find color or style 'bracket'.

Solution

I've submitted a PR #69 for fixing this issue by applying EscapeMarkup().

jeremydmiller commented 2 years ago

Fixed by https://github.com/JasperFx/oakton/pull/69