diff --git a/src/Spectre.Console/AnsiConsole.Prompt.cs b/src/Spectre.Console/AnsiConsole.Prompt.cs index f1a162b..c1bb92f 100644 --- a/src/Spectre.Console/AnsiConsole.Prompt.cs +++ b/src/Spectre.Console/AnsiConsole.Prompt.cs @@ -38,10 +38,15 @@ namespace Spectre.Console /// Displays a prompt with two choices, yes or no. /// /// The prompt markup text. + /// Specifies the default answer. /// true if the user selected "yes", otherwise false. - 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); } } } diff --git a/src/Spectre.Console/ConfirmationPrompt.cs b/src/Spectre.Console/ConfirmationPrompt.cs index 5ee9983..148f28e 100644 --- a/src/Spectre.Console/ConfirmationPrompt.cs +++ b/src/Spectre.Console/ConfirmationPrompt.cs @@ -17,6 +17,11 @@ namespace Spectre.Console /// public char No { get; set; } = 'n'; + /// + /// Gets or sets a value indicating whether "yes" is the default answer. + /// + public bool DefaultValue { get; set; } = true; + /// /// Gets or sets the message for invalid choices. /// @@ -51,7 +56,7 @@ namespace Spectre.Console .ValidationErrorMessage(InvalidChoiceMessage) .ShowChoices(ShowChoices) .ShowDefaultValue(ShowDefaultValue) - .DefaultValue(Yes) + .DefaultValue(DefaultValue ? Yes : No) .AddChoice(Yes) .AddChoice(No);