From 66e5b8e95e70afcccd71d35537c257090689865b Mon Sep 17 00:00:00 2001 From: Shaun Lawrie Date: Fri, 8 Dec 2023 00:28:28 +1300 Subject: [PATCH] Make default conditional --- PwshSpectreConsole/public/prompts/Read-SpectreText.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/PwshSpectreConsole/public/prompts/Read-SpectreText.ps1 b/PwshSpectreConsole/public/prompts/Read-SpectreText.ps1 index 8bd79794..8b5848f1 100644 --- a/PwshSpectreConsole/public/prompts/Read-SpectreText.ps1 +++ b/PwshSpectreConsole/public/prompts/Read-SpectreText.ps1 @@ -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 } \ No newline at end of file