From d52769f68857cc236797b37f15bcf842c7fb999c Mon Sep 17 00:00:00 2001 From: Jay <33441569+fmotion1@users.noreply.github.com> Date: Tue, 2 Jan 2024 02:45:57 -0600 Subject: [PATCH 1/3] Update Read-SpectreMultiSelection.ps1 Fixed AllowEmpty parameter being assigned to a non-existent property of the [MultiSelectionPromptExtensions] class. --- .../public/prompts/Read-SpectreMultiSelection.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelection.ps1 b/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelection.ps1 index 9b0852ee..ac929a1a 100644 --- a/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelection.ps1 +++ b/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelection.ps1 @@ -36,7 +36,7 @@ function Read-SpectreMultiSelection { [ArgumentCompletionsSpectreColors()] [string] $Color = $script:AccentColor.ToMarkup(), [int] $PageSize = 5, - [switch] $AllowEmpty + [switch] $RequireChoice ) $spectrePrompt = [Spectre.Console.MultiSelectionPrompt[string]]::new() @@ -55,7 +55,7 @@ function Read-SpectreMultiSelection { $spectrePrompt.Title = $Title $spectrePrompt.PageSize = $PageSize $spectrePrompt.WrapAround = $true - $spectrePrompt.AllowEmpty = $AllowEmpty + $spectrePrompt.Required = $RequireChoice $spectrePrompt.HighlightStyle = [Spectre.Console.Style]::new(($Color | Convert-ToSpectreColor)) $spectrePrompt.InstructionsText = "[$($script:DefaultValueColor.ToMarkup())](Press [$($script:AccentColor.ToMarkup())]space[/] to toggle a choice and press [$($script:AccentColor.ToMarkup())][/] to submit your answer)[/]" $spectrePrompt.MoreChoicesText = "[$($script:DefaultValueColor.ToMarkup())](Move up and down to reveal more choices)[/]" From 434a82a7e7c8753b26deeaeb96e9bc05b2d27ae4 Mon Sep 17 00:00:00 2001 From: fmotion1 Date: Tue, 2 Jan 2024 13:06:22 -0600 Subject: [PATCH 2/3] Ignore Working folder and update .gitignore This commit ignores the "Working/" folder and updates the .gitignore file. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 9ccb3e31..d19a6b65 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ pnpm-debug.log* # Exclude packages folder PwshSpectreConsole/packages + +# Exclude working folder +Working/ From 0f2bb34f805fd9130d1381e095330b7a9d3efe8d Mon Sep 17 00:00:00 2001 From: Shaun Lawrie Date: Wed, 3 Jan 2024 15:34:20 +1300 Subject: [PATCH 3/3] Mathc multiselectiongrouped --- .../public/prompts/Read-SpectreMultiSelection.ps1 | 7 +++++-- .../public/prompts/Read-SpectreMultiSelectionGrouped.ps1 | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelection.ps1 b/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelection.ps1 index ac929a1a..434b3c36 100644 --- a/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelection.ps1 +++ b/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelection.ps1 @@ -23,6 +23,9 @@ function Read-SpectreMultiSelection { .PARAMETER PageSize The number of choices to display per page. Defaults to 5. + .PARAMETER AllowEmpty + Allow the multi-selection to be submitted without any options chosen. + .EXAMPLE # Displays a multi-selection prompt with the title "Select your favourite fruits", the list of fruits, the "Name" property as the label for each fruit, the color green for highlighting the selected fruits, and 3 fruits per page. Read-SpectreMultiSelection -Title "Select your favourite fruits" -Choices @("apple", "banana", "orange", "pear", "strawberry") -Color "Green" -PageSize 3 @@ -36,7 +39,7 @@ function Read-SpectreMultiSelection { [ArgumentCompletionsSpectreColors()] [string] $Color = $script:AccentColor.ToMarkup(), [int] $PageSize = 5, - [switch] $RequireChoice + [switch] $AllowEmpty ) $spectrePrompt = [Spectre.Console.MultiSelectionPrompt[string]]::new() @@ -55,7 +58,7 @@ function Read-SpectreMultiSelection { $spectrePrompt.Title = $Title $spectrePrompt.PageSize = $PageSize $spectrePrompt.WrapAround = $true - $spectrePrompt.Required = $RequireChoice + $spectrePrompt.Required = !$AllowEmpty $spectrePrompt.HighlightStyle = [Spectre.Console.Style]::new(($Color | Convert-ToSpectreColor)) $spectrePrompt.InstructionsText = "[$($script:DefaultValueColor.ToMarkup())](Press [$($script:AccentColor.ToMarkup())]space[/] to toggle a choice and press [$($script:AccentColor.ToMarkup())][/] to submit your answer)[/]" $spectrePrompt.MoreChoicesText = "[$($script:DefaultValueColor.ToMarkup())](Move up and down to reveal more choices)[/]" diff --git a/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelectionGrouped.ps1 b/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelectionGrouped.ps1 index 28907ad3..e4fa8511 100644 --- a/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelectionGrouped.ps1 +++ b/PwshSpectreConsole/public/prompts/Read-SpectreMultiSelectionGrouped.ps1 @@ -23,6 +23,9 @@ function Read-SpectreMultiSelectionGrouped { .PARAMETER PageSize The number of choices to display per page. The default value is 10. + .PARAMETER AllowEmpty + Allow the multi-selection to be submitted without any options chosen. + .EXAMPLE # This example displays a multi-selection prompt with two groups of choices: "Primary Colors" and "Secondary Colors". The prompt uses the "Name" property of each choice as the label. The user can select one or more choices from each group. Read-SpectreMultiSelectionGrouped -Title "Select your favorite colors" -Choices @(