mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 08:52: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>
|
/// <remarks>
|
||||||
/// Defaults to <see cref="StringComparer.CurrentCultureIgnoreCase"/>.
|
/// Defaults to <see cref="StringComparer.CurrentCultureIgnoreCase"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public StringComparer ChoiceComparer { get; set; } = StringComparer.CurrentCultureIgnoreCase;
|
public StringComparer Comparer { get; set; } = StringComparer.CurrentCultureIgnoreCase;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ConfirmationPrompt"/> class.
|
/// Initializes a new instance of the <see cref="ConfirmationPrompt"/> class.
|
||||||
@ -66,7 +66,9 @@ public sealed class ConfirmationPrompt : IPrompt<bool>
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<bool> ShowAsync(IAnsiConsole console, CancellationToken cancellationToken)
|
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)
|
.InvalidChoiceMessage(InvalidChoiceMessage)
|
||||||
.ValidationErrorMessage(InvalidChoiceMessage)
|
.ValidationErrorMessage(InvalidChoiceMessage)
|
||||||
.ShowChoices(ShowChoices)
|
.ShowChoices(ShowChoices)
|
||||||
@ -77,6 +79,6 @@ public sealed class ConfirmationPrompt : IPrompt<bool>
|
|||||||
|
|
||||||
var result = await prompt.ShowAsync(console, cancellationToken).ConfigureAwait(false);
|
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