using System; namespace Spectre.Console { /// /// Contains extension methods for . /// public static class ConfirmationPromptExtensions { /// /// Show or hide choices. /// /// The prompt. /// Whether or not the choices should be visible. /// The same instance so that multiple calls can be chained. public static ConfirmationPrompt ShowChoices(this ConfirmationPrompt obj, bool show) { if (obj is null) { throw new ArgumentNullException(nameof(obj)); } obj.ShowChoices = show; return obj; } /// /// Shows choices. /// /// The prompt. /// The same instance so that multiple calls can be chained. public static ConfirmationPrompt ShowChoices(this ConfirmationPrompt obj) { return ShowChoices(obj, true); } /// /// Hides choices. /// /// The prompt. /// The same instance so that multiple calls can be chained. public static ConfirmationPrompt HideChoices(this ConfirmationPrompt obj) { return ShowChoices(obj, false); } /// /// Show or hide the default value. /// /// The prompt. /// Whether or not the default value should be visible. /// The same instance so that multiple calls can be chained. public static ConfirmationPrompt ShowDefaultValue(this ConfirmationPrompt obj, bool show) { if (obj is null) { throw new ArgumentNullException(nameof(obj)); } obj.ShowDefaultValue = show; return obj; } /// /// Shows the default value. /// /// The prompt. /// The same instance so that multiple calls can be chained. public static ConfirmationPrompt ShowDefaultValue(this ConfirmationPrompt obj) { return ShowDefaultValue(obj, true); } /// /// Hides the default value. /// /// The prompt. /// The same instance so that multiple calls can be chained. public static ConfirmationPrompt HideDefaultValue(this ConfirmationPrompt obj) { return ShowDefaultValue(obj, false); } /// /// Sets the "invalid choice" message for the prompt. /// /// The prompt. /// The "invalid choice" message. /// The same instance so that multiple calls can be chained. public static ConfirmationPrompt InvalidChoiceMessage(this ConfirmationPrompt obj, string message) { if (obj is null) { throw new ArgumentNullException(nameof(obj)); } obj.InvalidChoiceMessage = message; return obj; } /// /// Sets the character to interpret as "yes". /// /// The confirmation prompt. /// The character to interpret as "yes". /// The same instance so that multiple calls can be chained. public static ConfirmationPrompt Yes(this ConfirmationPrompt obj, char character) { if (obj is null) { throw new ArgumentNullException(nameof(obj)); } obj.Yes = character; return obj; } /// /// Sets the character to interpret as "no". /// /// The confirmation prompt. /// The character to interpret as "no". /// The same instance so that multiple calls can be chained. public static ConfirmationPrompt No(this ConfirmationPrompt obj, char character) { if (obj is null) { throw new ArgumentNullException(nameof(obj)); } obj.No = character; return obj; } } }