mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Add culture option to TypeConverterHelper, TextPrompt and AnsiConsole (#1014)
* Add culture option to TypeConverterHelper, TextPrompt and AnsiConsole * Add IHasCulture interface
This commit is contained in:
@ -34,6 +34,21 @@ public static partial class AnsiConsoleExtensions
|
||||
return new TextPrompt<T>(prompt).Show(console);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a prompt to the user.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The prompt result type.</typeparam>
|
||||
/// <param name="console">The console.</param>
|
||||
/// <param name="prompt">The prompt markup text.</param>
|
||||
/// <param name="culture">Specific CultureInfo to use when converting input.</param>
|
||||
/// <returns>The prompt input result.</returns>
|
||||
public static T Ask<T>(this IAnsiConsole console, string prompt, CultureInfo? culture)
|
||||
{
|
||||
var textPrompt = new TextPrompt<T>(prompt);
|
||||
textPrompt.Culture = culture;
|
||||
return textPrompt.Show(console);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a prompt with two choices, yes or no.
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user