Allow custom instructions for prompts

Closes #229
This commit is contained in:
Patrik Svensson
2021-03-14 23:35:08 +01:00
committed by Phil Scott
parent 9502aaf2b9
commit c2bab0ebf8
9 changed files with 105 additions and 9 deletions

View File

@ -188,6 +188,42 @@ namespace Spectre.Console
return obj;
}
/// <summary>
/// Sets the text that will be displayed if there are more choices to show.
/// </summary>
/// <typeparam name="T">The prompt result type.</typeparam>
/// <param name="obj">The prompt.</param>
/// <param name="text">The text to display.</param>
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static MultiSelectionPrompt<T> MoreChoicesText<T>(this MultiSelectionPrompt<T> obj, string? text)
{
if (obj is null)
{
throw new ArgumentNullException(nameof(obj));
}
obj.MoreChoicesText = text;
return obj;
}
/// <summary>
/// Sets the text that instructs the user of how to select items.
/// </summary>
/// <typeparam name="T">The prompt result type.</typeparam>
/// <param name="obj">The prompt.</param>
/// <param name="text">The text to display.</param>
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static MultiSelectionPrompt<T> InstructionsText<T>(this MultiSelectionPrompt<T> obj, string? text)
{
if (obj is null)
{
throw new ArgumentNullException(nameof(obj));
}
obj.InstructionsText = text;
return obj;
}
/// <summary>
/// Requires no choice to be selected.
/// </summary>