Read-SpectreMultiSelectionGrouped
Description
Displays a multi-selection prompt with grouped choices and returns the selected choices. The prompt allows the user to select one or more choices from a list of options. The choices can be grouped into categories, and the user can select choices from each category.
Examples
Example 1
This example demonstrates a multi-selection prompt with grouped choices.
$selected = Read-SpectreMultiSelectionGrouped -Message "Select your favorite colors" -PageSize 8 -Choices @(
@{
Name = "Primary Colors"
Choices = @("Red", "Blue", "Yellow")
},
@{
Name = "Secondary Colors"
Choices = @("Green", "Orange", "Purple")
}
)
# Type "↓", "<space>", "↓", "↓", "↓", "<space>", "↲" to choose red and all secondary colors
Write-SpectreHost "Your favourite colors are $($selected -join ', ')"
Parameters
Message
The title of the prompt. The default value is “What are your favourite [Spectre.Console.Color]?“.
Type | Required | Position | PipelineInput | Aliases |
---|---|---|---|---|
[String] | false | 1 | false | Title Question Prompt |
Choices
An array of choice groups. Each group is a hashtable with two keys: “Name” and “Choices”. The “Name” key is a string that represents the name of the group, and the “Choices” key is an array of strings that represents the choices in the group.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Array] | true | 2 | false |
ChoiceLabelProperty
The name of the property to use as the label for each choice. If this parameter is not specified, the choices are displayed as strings.
Type | Required | Position | PipelineInput |
---|---|---|---|
[String] | false | 3 | false |
Color
The color of the selected choices. The default value is the accent color of the script.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Color] | false | 4 | false |
PageSize
The number of choices to display per page. The default value is 10.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Int32] | false | 5 | false |
TimeoutSeconds
Type | Required | Position | PipelineInput |
---|---|---|---|
[Int32] | false | 6 | false |
AllowEmpty
Allow the multi-selection to be submitted without any options chosen.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Switch] | false | named | false |
Syntax
Read-SpectreMultiSelectionGrouped [[-Message] <String>] [-Choices] <Array> [[-ChoiceLabelProperty] <String>] [[-Color] <Color>] [[-PageSize] <Int32>] [[-TimeoutSeconds] <Int32>] [-AllowEmpty] [<CommonParameters>]