11function Get-ListPanel {
2+ <#
3+ . SYNOPSIS
4+ Create a list panel for displaying items in a TUI.
5+
6+ . DESCRIPTION
7+ This function generates a list panel that displays items in a TUI (Text User
8+ Interface) using Spectre.Console. It formats the items based on whether they
9+ are selected or not, and handles special cases like parent directories.
10+
11+ . PARAMETER List
12+ An array of strings to display in the list. Each item can be a file path,
13+ a test name, or a special item like '..' for parent directories.
14+
15+ . PARAMETER SelectedItem
16+ The item that is currently selected in the list. This will be highlighted
17+ differently from unselected items.
18+
19+ . EXAMPLE
20+ Get-ListPanel -List @('file1.txt', 'file2.txt', '..') -SelectedItem 'file1.txt'
21+
22+ This example creates a list panel with three items, highlighting 'file1.txt'
23+ as the selected item.
24+ . NOTES
25+ This is meant to be called by the main TUI function: Show-PesterResult
26+ #>
227 [CmdletBinding ()]
328 param (
429 [array ]
@@ -17,9 +42,11 @@ function Get-ListPanel {
1742 if ($name -eq ' ..' ) {
1843 # This is a parent item, so we show it as a folder
1944 if ($name -eq $SelectedItem ) {
20- Write-SpectreHost " :up_arrow: [Turquoise2]$name [/]" - PassThru | Format-SpectrePadded - Padding 1
45+ Write-SpectreHost " :up_arrow: [Turquoise2]$name [/]" - PassThru |
46+ Format-SpectrePadded - Padding 1
2147 } else {
22- Write-SpectreHost " $name " - PassThru | Format-SpectrePadded - Padding 0
48+ Write-SpectreHost " $name " - PassThru |
49+ Format-SpectrePadded - Padding 0
2350 }
2451 }
2552 elseif (Test-Path $name ){
@@ -28,18 +55,32 @@ function Get-ListPanel {
2855 $name
2956 )
3057 if ($name -eq $SelectedItem ) {
31- Format-SpectreTextPath - Path $relativePath | Format-SpectrePadded - Padding 1
58+ Format-SpectreTextPath - Path $relativePath |
59+ Format-SpectrePadded - Padding 1
3260 } else {
33- Format-SpectreTextPath - Path $relativePath - PathStyle $unselectedStyle | Format-SpectrePadded - Padding 0
61+ $formatSpectreTextPathSplat = @ {
62+ Path = $relativePath
63+ PathStyle = $unselectedStyle
64+ }
65+ Format-SpectreTextPath @formatSpectreTextPathSplat |
66+ Format-SpectrePadded - Padding 0
3467 }
3568 }
3669 else {
3770 if ($name -eq $SelectedItem ) {
38- Write-SpectreHost " :right_arrow: [Turquoise2]$name [/]" - PassThru | Format-SpectrePadded - Padding 1
71+ $writeSpectreHostSplat = @ {
72+ PassThru = $true
73+ Message = " :right_arrow: [Turquoise2]$name [/]"
74+ }
75+ Write-SpectreHost @writeSpectreHostSplat |
76+ Format-SpectrePadded - Padding 1
3977 } else {
40- Write-SpectreHost $name - PassThru | Format-SpectrePadded - Padding 0
78+ Write-SpectreHost $name - PassThru |
79+ Format-SpectrePadded - Padding 0
4180 }
4281 }
4382 }
44- $results | Format-SpectreRows | Format-SpectrePanel - Header " [white]List[/]" - Expand
83+ $results |
84+ Format-SpectreRows |
85+ Format-SpectrePanel - Header " [white]List[/]" - Expand
4586}
0 commit comments