Skip to content

Commit

Permalink
Make default conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaunLawrie authored Dec 7, 2023
1 parent b47aed4 commit 66e5b8e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions PwshSpectreConsole/public/prompts/Read-SpectreText.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ function Read-SpectreText {
[Reflection.AssemblyMetadata("title", "Read-SpectreText")]
param (
[string] $Question = "What's your name?",
[string] $DefaultAnswer = "Prefer not to say"
[string] $DefaultAnswer
)
$prompt = [Spectre.Console.TextPrompt[string]]::new($Question)
$prompt.DefaultValueStyle = [Spectre.Console.Style]::new($script:DefaultValueColor)
$prompt = [Spectre.Console.TextPromptExtensions]::DefaultValue($prompt, $DefaultAnswer)
if($DefaultAnswer) {
$prompt = [Spectre.Console.TextPromptExtensions]::DefaultValue($prompt, $DefaultAnswer)
}
return Invoke-SpectrePromptAsync -Prompt $prompt
}

0 comments on commit 66e5b8e

Please sign in to comment.