feat: Allow case-insensitive confirmation prompt

This commit is contained in:
Martin Zikmund 2023-02-04 13:24:11 +01:00
parent e042fe15e4
commit 720db951f3

View File

@ -39,6 +39,12 @@ public sealed class ConfirmationPrompt : IPrompt<bool>
/// </summary>
public bool ShowDefaultValue { get; set; } = true;
/// <summary>
/// Gets or sets a value indicating whether the confirmation
/// should use case insensitive matching.
/// </summary>
public bool CaseInsensitive { get; set; } = true;
/// <summary>
/// Initializes a new instance of the <see cref="ConfirmationPrompt"/> class.
/// </summary>
@ -67,6 +73,7 @@ public sealed class ConfirmationPrompt : IPrompt<bool>
.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);
}
}