add overload taking params array (#682)

This commit is contained in:
Steven 2022-01-15 13:51:17 -05:00 committed by GitHub
parent 0b988ff65c
commit f221c1f25c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 0 deletions

View File

@ -122,6 +122,31 @@ public static class MultiSelectionPromptExtensions
return obj;
}
/// <summary>
/// Adds multiple grouped choices.
/// </summary>
/// <typeparam name="T">The prompt result type.</typeparam>
/// <param name="obj">The prompt.</param>
/// <param name="group">The group.</param>
/// <param name="choices">The choices to add.</param>
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static MultiSelectionPrompt<T> AddChoiceGroup<T>(this MultiSelectionPrompt<T> obj, T group, params T[] choices)
where T : notnull
{
if (obj is null)
{
throw new ArgumentNullException(nameof(obj));
}
var root = obj.AddChoice(group);
foreach (var choice in choices)
{
root.AddChild(choice);
}
return obj;
}
/// <summary>
/// Marks an item as selected.
/// </summary>

View File

@ -95,6 +95,31 @@ public static class SelectionPromptExtensions
return obj;
}
/// <summary>
/// Adds multiple grouped choices.
/// </summary>
/// <typeparam name="T">The prompt result type.</typeparam>
/// <param name="obj">The prompt.</param>
/// <param name="group">The group.</param>
/// <param name="choices">The choices to add.</param>
/// <returns>The same instance so that multiple calls can be chained.</returns>
public static SelectionPrompt<T> AddChoiceGroup<T>(this SelectionPrompt<T> obj, T group, params T[] choices)
where T : notnull
{
if (obj is null)
{
throw new ArgumentNullException(nameof(obj));
}
var root = obj.AddChoice(group);
foreach (var choice in choices)
{
root.AddChild(choice);
}
return obj;
}
/// <summary>
/// Sets the title.
/// </summary>