oakton icon indicating copy to clipboard operation
oakton copied to clipboard

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

Open kuanpak opened this issue 1 year ago • 0 comments

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().

kuanpak avatar Sep 28 '22 02:09 kuanpak