Add default value parameter to Confirm extension

Closes #482
This commit is contained in:
Antonio Valentini
2021-07-12 08:47:36 +02:00
committed by GitHub
parent 5f97f2300c
commit d532e1011f
2 changed files with 36 additions and 2 deletions

View File

@ -41,10 +41,15 @@ namespace Spectre.Console
/// </summary>
/// <param name="console">The console.</param>
/// <param name="prompt">The prompt markup text.</param>
/// <param name="defaultValue">Specifies the default answer.</param>
/// <returns><c>true</c> if the user selected "yes", otherwise <c>false</c>.</returns>
public static bool Confirm(this IAnsiConsole console, string prompt)
public static bool Confirm(this IAnsiConsole console, string prompt, bool defaultValue = true)
{
return new ConfirmationPrompt(prompt).Show(console);
return new ConfirmationPrompt(prompt)
{
DefaultValue = defaultValue,
}
.Show(console);
}
}
}