mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 08:52:50 +08:00
add overload taking params array (#682)
This commit is contained in:
parent
0b988ff65c
commit
f221c1f25c
@ -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>
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user