diff --git a/PwshSpectreConsole/public/PwshSpectreConsole.ps1 b/PwshSpectreConsole/public/PwshSpectreConsole.ps1 index 0bac877c..096bf285 100644 --- a/PwshSpectreConsole/public/PwshSpectreConsole.ps1 +++ b/PwshSpectreConsole/public/PwshSpectreConsole.ps1 @@ -183,7 +183,10 @@ function Read-SpectreConfirm { [ValidateSet("y", "n")] [string] $DefaultAnswer = "y", [string] $ConfirmSuccess, - [string] $ConfirmFailure + [string] $ConfirmFailure, + [ValidateSpectreColor()] + [ArgumentCompletionsSpectreColors()] + [string] $Color = $script:AccentColor.ToMarkup() ) # This is much fiddlier but it exposes the ability to set the color scheme. The confirmationprompt is just a textprompt with two choices hard coded to y/n: @@ -195,7 +198,7 @@ function Read-SpectreConfirm { # This is how I added the default colors with Set-SpectreColors so you don't have to keep passing them through and get a consistent TUI color scheme $confirmationPrompt.DefaultValueStyle = [Spectre.Console.Style]::new($script:DefaultValueColor) - $confirmationPrompt.ChoicesStyle = [Spectre.Console.Style]::new($script:AccentColor) + $confirmationPrompt.ChoicesStyle = [Spectre.Console.Style]::new(($Color | Convert-ToSpectreColor)) $confirmationPrompt.InvalidChoiceMessage = "[red]Please select one of the available options[/]" # Invoke-SpectrePromptAsync supports ctrl-c diff --git a/PwshSpectreConsole/public/PwshSpectreConsoleDemo.ps1 b/PwshSpectreConsole/public/PwshSpectreConsoleDemo.ps1 index ca1e31d4..40d07613 100644 --- a/PwshSpectreConsole/public/PwshSpectreConsoleDemo.ps1 +++ b/PwshSpectreConsole/public/PwshSpectreConsoleDemo.ps1 @@ -70,6 +70,13 @@ $name = Read-SpectreText "What's your [blue]name[/]?" $example | Invoke-Expression Clear-Host + $example = @' +$answer = Read-SpectreConfirm -Prompt "Do you like cute animals?" -DefaultAnswer "y" +'@ + $example | Write-SpectreExample -Title "Confirmation" -Description "Confirmation prompts are used to confirm an action or decision before it is executed. They help prevent users from making mistakes or taking actions they did not intend to, reducing the chances of errors and improving the overall user experience." + $example | Invoke-Expression + Clear-Host + $example = @' $choices = @("Sushi", "Tacos", "Pad Thai", "Lobster", "Falafel", "Chicken Parmesan", "Ramen", "Fish and Chips", "Biryani", "Croissants", "Enchiladas", "Shepherd's Pie", "Gyoza", "Fajitas", "Samosas", "Bruschetta", "Paella", "Hamburger", "Poutine", "Ceviche")