Make default answer for confirmation prompt configurable

This commit is contained in:
Thomas Freudenberg
2021-02-15 11:08:47 +01:00
committed by Patrik Svensson
parent 04d0e663d5
commit ed0fb29be4
2 changed files with 13 additions and 3 deletions

View File

@@ -38,10 +38,15 @@ namespace Spectre.Console
/// Displays a prompt with two choices, yes or no.
/// </summary>
/// <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(string prompt)
public static bool Confirm(string prompt, bool defaultValue = true)
{
return new ConfirmationPrompt(prompt).Show(Console);
return new ConfirmationPrompt(prompt)
{
DefaultValue = defaultValue,
}
.Show(Console);
}
}
}