Skip to content

Commit

Permalink
Merge pull request #22 from csillikd/add-choices-to-read-spectratext
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaunLawrie authored Jan 18, 2024
2 parents be9418d + 450856c commit 63abd20
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion PwshSpectreConsole/public/prompts/Read-SpectreText.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ function Read-SpectreText {
[ValidateSpectreColor()]
[ArgumentCompletionsSpectreColors()]
[string] $AnswerColor,
[switch] $AllowEmpty
[switch] $AllowEmpty,
[string[]] $Choices
)
$spectrePrompt = [Spectre.Console.TextPrompt[string]]::new($Question)
$spectrePrompt.DefaultValueStyle = [Spectre.Console.Style]::new($script:DefaultValueColor)
Expand All @@ -43,5 +44,9 @@ function Read-SpectreText {
$spectrePrompt.PromptStyle = [Spectre.Console.Style]::new(($AnswerColor | Convert-ToSpectreColor))
}
$spectrePrompt.AllowEmpty = $AllowEmpty
if ($null -ne $Choices)
{
$spectrePrompt = [Spectre.Console.TextPromptExtensions]::AddChoices($spectrePrompt, $Choices)
}
return Invoke-SpectrePromptAsync -Prompt $spectrePrompt
}

0 comments on commit 63abd20

Please sign in to comment.