fix color formatting core dump
This commit is contained in:
@@ -38,22 +38,30 @@ public static class OperationForms
|
||||
if (error is not null)
|
||||
AnsiConsole.MarkupLine($"[yellow][[WARN]] Could not fetch schemas: {Markup.Escape(error)}[/]");
|
||||
|
||||
var choices = new List<string>(schemas);
|
||||
choices.Add("[dim][ Enter manually ][/]");
|
||||
choices.Add("[dim][ Cancel ][/]");
|
||||
// Use sentinel strings as values so no markup leaks into choice labels
|
||||
const string manualSentinel = "__MANUAL__";
|
||||
const string cancelSentinel = "__CANCEL__";
|
||||
|
||||
var choiceValues = new List<string>(schemas) { manualSentinel, cancelSentinel };
|
||||
|
||||
var prompt = new SelectionPrompt<string>()
|
||||
.Title($"[bold]{title}[/]")
|
||||
.Title($"[bold]{Markup.Escape(title)}[/]")
|
||||
.PageSize(15)
|
||||
.HighlightStyle(Style.Parse("bold dodgerblue1"))
|
||||
.AddChoices(choices);
|
||||
.UseConverter(v => v switch
|
||||
{
|
||||
manualSentinel => "[ Enter manually ]",
|
||||
cancelSentinel => "[ Cancel ]",
|
||||
_ => v,
|
||||
})
|
||||
.AddChoices(choiceValues);
|
||||
|
||||
var selected = AnsiConsole.Prompt(prompt);
|
||||
|
||||
if (selected.Contains("Cancel"))
|
||||
if (selected == cancelSentinel)
|
||||
return null;
|
||||
|
||||
if (selected.Contains("manually"))
|
||||
if (selected == manualSentinel)
|
||||
{
|
||||
var manual = AnsiConsole.Ask<string>("Enter schema name:").Trim();
|
||||
return string.IsNullOrWhiteSpace(manual) ? null : manual;
|
||||
|
||||
Reference in New Issue
Block a user