mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-14 16:02:50 +08:00
Adjustments based on code review
This commit is contained in:
parent
9cd7b24e65
commit
5075732564
@ -46,7 +46,7 @@ public sealed class ConfirmationPrompt : IPrompt<bool>
|
||||
/// <remarks>
|
||||
/// Defaults to <see cref="StringComparer.CurrentCultureIgnoreCase"/>.
|
||||
/// </remarks>
|
||||
public StringComparer ChoiceComparer { get; set; } = StringComparer.CurrentCultureIgnoreCase;
|
||||
public StringComparer Comparer { get; set; } = StringComparer.CurrentCultureIgnoreCase;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ConfirmationPrompt"/> class.
|
||||
@ -66,7 +66,9 @@ public sealed class ConfirmationPrompt : IPrompt<bool>
|
||||
/// <inheritdoc/>
|
||||
public async Task<bool> ShowAsync(IAnsiConsole console, CancellationToken cancellationToken)
|
||||
{
|
||||
var prompt = new TextPrompt<char>(_prompt, ChoiceComparer)
|
||||
var comparer = Comparer ?? StringComparer.CurrentCultureIgnoreCase;
|
||||
|
||||
var prompt = new TextPrompt<char>(_prompt, comparer)
|
||||
.InvalidChoiceMessage(InvalidChoiceMessage)
|
||||
.ValidationErrorMessage(InvalidChoiceMessage)
|
||||
.ShowChoices(ShowChoices)
|
||||
@ -77,6 +79,6 @@ public sealed class ConfirmationPrompt : IPrompt<bool>
|
||||
|
||||
var result = await prompt.ShowAsync(console, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return ChoiceComparer.Compare(Yes.ToString(), result.ToString()) == 0;
|
||||
return comparer.Compare(Yes.ToString(), result.ToString()) == 0;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user