Represents a multi selection list prompt.
Constructors
public MultiSelectionPrompt`1(IEqualityComparer<T> comparer = null)
Initializes a new instance of the MultiSelectionPrompt class.
Parameters:
comparer (IEqualityComparer<T>)IEqualityComparer implementation to use when comparing items, or null to use the default IEqualityComparer for the type of the item.Properties
CancelResult
: Func<List<T>>Gets or sets a Func that will be triggered if Cancel is triggered by the 'ESC' key.
Converter
: Func<T, string>Gets or sets the converter to get the display string for a choice. By default the corresponding TypeConverter is used.
DefaultValue
: TGets or sets the choice to show as selected when the prompt is first displayed. By default the first choice is selected.
InstructionsText
: stringGets or sets the text that instructs the user of how to select items.
Mode
: SelectionModeGets or sets the selection mode. Defaults to Leaf.
MoreChoicesText
: stringGets or sets the text that will be displayed if there are more choices to show.
PageSize
: intGets or sets the page size. Defaults to 10.
Required
: boolGets or sets a value indicating whether or not at least one selection is required.
Title
: stringGets or sets the title.
WrapAround
: boolGets or sets a value indicating whether the selection should wrap around when reaching the edge. Defaults to false.
Methods
public IMultiSelectionItem<T> AddChoice(T item)
Adds a choice.
Parameters:
item (T)Returns:
A IMultiSelectionItem so that multiple calls can be chained.
public T GetParent(T item)
Returns the parent item of the given item.
Parameters:
item (T)Returns:
The parent item, or null if the given item has no parent.
public IEnumerable<T> GetParents(T item)
Returns all parent items of the given item.
Parameters:
item (T)Returns:
The parent items, or an empty list, if the given item has no parents.
public List<T> Show(IAnsiConsole console)
Shows the prompt.
Parameters:
console (IAnsiConsole)Returns:
The prompt input result.
public Task<List<T>> ShowAsync(IAnsiConsole console, CancellationToken cancellationToken)
Shows the prompt asynchronously.
Parameters:
console (IAnsiConsole)cancellationToken (CancellationToken)Returns:
The prompt input result.
Extension Methods
MultiSelectionPrompt<T> AddChoiceGroup<T>(this MultiSelectionPrompt<T> obj, T group, T[] choices)Adds multiple grouped choices.
Returns:
The same instance so that multiple calls can be chained.
MultiSelectionPrompt<T> AddChoiceGroup<T>(this MultiSelectionPrompt<T> obj, T group, IEnumerable<T> choices)Adds multiple grouped choices.
Returns:
The same instance so that multiple calls can be chained.
MultiSelectionPrompt<T> AddChoices<T>(this MultiSelectionPrompt<T> obj, T[] choices)Adds multiple choices.
Returns:
The same instance so that multiple calls can be chained.
MultiSelectionPrompt<T> AddChoices<T>(this MultiSelectionPrompt<T> obj, IEnumerable<T> choices)Adds multiple choices.
Returns:
The same instance so that multiple calls can be chained.
MultiSelectionPrompt<T> AddChoices<T>(this MultiSelectionPrompt<T> obj, T choice, Action<IMultiSelectionItem<T>> configurator)Adds a choice.
Returns:
The same instance so that multiple calls can be chained.
MultiSelectionPrompt<T> Mode<T>(this MultiSelectionPrompt<T> obj, SelectionMode mode)Sets the selection mode.
Returns:
The same instance so that multiple calls can be chained.
MultiSelectionPrompt<T> PageSize<T>(this MultiSelectionPrompt<T> obj, int pageSize)Sets how many choices that are displayed to the user.
Returns:
The same instance so that multiple calls can be chained.
MultiSelectionPrompt<T> Select<T>(this MultiSelectionPrompt<T> obj, T item)Marks an item as selected.
Returns:
The same instance so that multiple calls can be chained.
MultiSelectionPrompt<T> Title<T>(this MultiSelectionPrompt<T> obj, string title)Sets the title.
Returns:
The same instance so that multiple calls can be chained.
MultiSelectionPrompt<T> WrapAround<T>(this MultiSelectionPrompt<T> obj, bool shouldWrap)Sets whether the selection should wrap around when reaching its edges.
Returns:
The same instance so that multiple calls can be chained.