From 6b11669036989cf38567edef78cd496ef8a5405b Mon Sep 17 00:00:00 2001 From: Shaun Lawrie Date: Mon, 11 Nov 2024 23:24:38 +1300 Subject: [PATCH] Minor tweaks for params for bluesky client --- .../public/formatting/Format-SpectreGrid.ps1 | 17 ++++++++++++++--- .../public/formatting/Format-SpectrePanel.ps1 | 2 +- .../public/formatting/Format-SpectreTable.ps1 | 4 +++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/PwshSpectreConsole/public/formatting/Format-SpectreGrid.ps1 b/PwshSpectreConsole/public/formatting/Format-SpectreGrid.ps1 index eb8ea47..40db635 100644 --- a/PwshSpectreConsole/public/formatting/Format-SpectreGrid.ps1 +++ b/PwshSpectreConsole/public/formatting/Format-SpectreGrid.ps1 @@ -9,6 +9,15 @@ function Format-SpectreGrid { Formats data into a Spectre Console grid. The grid can be used to display data in a tabular format but it's not as flexible as the Layout widget. See https://spectreconsole.net/widgets/grid for more information. + .PARAMETER Data + The data to be displayed in the grid. This can be a list of lists or a list of `New-SpectreGridRow` objects. + + .PARAMETER Width + The width of the grid. If not specified, the grid width will be automatic. + + .PARAMETER Padding + The padding to apply to the grid items. The default is 1. + .EXAMPLE # **Example 1** # This example demonstrates how to display a grid of rows using the Spectre Console module with a list of lists. @@ -37,7 +46,8 @@ function Format-SpectreGrid { [Parameter(ValueFromPipeline, Mandatory)] [GridRowTransformationAttribute()] [object]$Data, - [int] $Width + [int] $Width, + [int] $Padding = 1 ) begin { @@ -47,6 +57,7 @@ function Format-SpectreGrid { $grid.Width = $Width } $grid.Alignment = [Spectre.Console.Justify]::$Justify + $col = [Spectre.Console.GridColumn]::new() $grid = $grid.AddColumn() } @@ -55,7 +66,7 @@ function Format-SpectreGrid { foreach ($row in $Data) { if (!$columnsSet) { 0..($row.Count() - 1) | ForEach-Object { - $grid = $grid.AddColumn() + $grid = $grid.AddColumn($col) } $columnsSet = $true } @@ -64,7 +75,7 @@ function Format-SpectreGrid { } else { if (!$columnsSet) { 0..($row.Count() - 1) | ForEach-Object { - $grid = $grid.AddColumn() + $grid = $grid.AddColumn($col) } $columnsSet = $true } diff --git a/PwshSpectreConsole/public/formatting/Format-SpectrePanel.ps1 b/PwshSpectreConsole/public/formatting/Format-SpectrePanel.ps1 index 2671d95..9e14274 100644 --- a/PwshSpectreConsole/public/formatting/Format-SpectrePanel.ps1 +++ b/PwshSpectreConsole/public/formatting/Format-SpectrePanel.ps1 @@ -56,7 +56,7 @@ function Format-SpectrePanel { [Spectre.Console.Color] $Color = $script:AccentColor, [ValidateScript({ $_ -gt 0 -and $_ -le (Get-HostWidth) }, ErrorMessage = "Value '{0}' is invalid. Cannot be negative or exceed console width.")] [int]$Width, - [ValidateScript({ $_ -gt 0 -and $_ -le (Get-HostHeight) }, ErrorMessage = "Value '{0}' is invalid. Cannot be negative or exceed console height.")] + [ValidateScript({ $_ -gt 0 }, ErrorMessage = "Value '{0}' is invalid. Cannot be negative.")] [int]$Height ) diff --git a/PwshSpectreConsole/public/formatting/Format-SpectreTable.ps1 b/PwshSpectreConsole/public/formatting/Format-SpectreTable.ps1 index 534798f..b1582ec 100644 --- a/PwshSpectreConsole/public/formatting/Format-SpectreTable.ps1 +++ b/PwshSpectreConsole/public/formatting/Format-SpectreTable.ps1 @@ -132,7 +132,8 @@ function Format-SpectreTable { [int] $Width, [switch] $HideHeaders, [String] $Title, - [switch] $AllowMarkup + [switch] $AllowMarkup, + [switch] $Expand ) begin { Write-Debug "Module: $($ExecutionContext.SessionState.Module.Name) Command: $($MyInvocation.MyCommand.Name) Param: $($PSBoundParameters.GetEnumerator())" @@ -152,6 +153,7 @@ function Format-SpectreTable { 'Wrap' { $tableoptions.Wrap = $true ; $FormatTableParams.Wrap = $true } 'View' { $FormatTableParams.View = $View } 'Property' { $FormatTableParams.Property = $Property } + 'Expand' { $table.Expand = $Expand } } } process {