spectre.console icon indicating copy to clipboard operation
spectre.console copied to clipboard

AnsiConsole.Confirm and ConfirmationPrompt should offer an optional parameter to customize the TextPrompt.ChoicesStyle

Open IntegerMan opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe. I like to provide a means for customizing the console theme to the user. As part of this, I want to be able to control the styles that Spectre.Console uses for every interaction. Right now if I do an AnsiConsole.Confirm call, there is no way of controlling the color of the blue [y/n] text that displays. This belongs to the TextPrompt class that ConfirmationPrompt.ShowAsync creates, but nothing calls to its ChoicesStyle method.

Describe the solution you'd like I'd like ConfirmationPrompt to get a ChoicesStyle property that gets sent to TextPrompt as part of ShowAsync. I'd like AnsiConsole.Confirm to get an optional parameter for choicesStyle that sets the ChoicesStyle of the ConfirmationPrompt it creates. These values can default to blue, which is the current style.

Describe alternatives you've considered A more comprehensive alternative would be to have Spectre.Console rely on a Skin class that contains common styles that can be passed around, but this would be a much larger and more invasive change.

Additional context I can currently work around this by creating my own extension method that re-implements ConfirmationPrompt. If ConfirmationPrompt were not sealed and ShowAsync were virtual, it'd be less invasive for me to work around things. The sealed design does get in the way in some places. For example, I wanted to subclass Tree at one point in the last week to make a specialized form of tree, but the inheritance and restrictions prevented me from doing anything meaningful there, and enough things in Renderables were internal or sealed that I had to go a non-object-oriented route trying to accomplish what I needed there.


Please upvote :+1: this issue if you are interested in it.

IntegerMan avatar Nov 18 '23 20:11 IntegerMan