From 720db951f35cdd9c5ab7fee495ee3ee501e34d49 Mon Sep 17 00:00:00 2001 From: Martin Zikmund Date: Sat, 4 Feb 2023 13:24:11 +0100 Subject: [PATCH] feat: Allow case-insensitive confirmation prompt --- src/Spectre.Console/Prompts/ConfirmationPrompt.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Spectre.Console/Prompts/ConfirmationPrompt.cs b/src/Spectre.Console/Prompts/ConfirmationPrompt.cs index 9a17bd3..bedfb2e 100644 --- a/src/Spectre.Console/Prompts/ConfirmationPrompt.cs +++ b/src/Spectre.Console/Prompts/ConfirmationPrompt.cs @@ -39,6 +39,12 @@ public sealed class ConfirmationPrompt : IPrompt /// public bool ShowDefaultValue { get; set; } = true; + /// + /// Gets or sets a value indicating whether the confirmation + /// should use case insensitive matching. + /// + public bool CaseInsensitive { get; set; } = true; + /// /// Initializes a new instance of the class. /// @@ -67,6 +73,7 @@ public sealed class ConfirmationPrompt : IPrompt .AddChoice(No); var result = await prompt.ShowAsync(console, cancellationToken).ConfigureAwait(false); - return result == Yes; + + return Yes.ToString().Equals(result.ToString(), CaseInsensitive ? StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture); } } \ No newline at end of file