Skip to content

Commit

Permalink
Minor tweaks for params for bluesky client
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaunLawrie committed Nov 11, 2024
1 parent dd91ba2 commit 6b11669
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
17 changes: 14 additions & 3 deletions PwshSpectreConsole/public/formatting/Format-SpectreGrid.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -37,7 +46,8 @@ function Format-SpectreGrid {
[Parameter(ValueFromPipeline, Mandatory)]
[GridRowTransformationAttribute()]
[object]$Data,
[int] $Width
[int] $Width,
[int] $Padding = 1
)

begin {
Expand All @@ -47,6 +57,7 @@ function Format-SpectreGrid {
$grid.Width = $Width
}
$grid.Alignment = [Spectre.Console.Justify]::$Justify
$col = [Spectre.Console.GridColumn]::new()
$grid = $grid.AddColumn()
}

Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
4 changes: 3 additions & 1 deletion PwshSpectreConsole/public/formatting/Format-SpectreTable.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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())"
Expand All @@ -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 {
Expand Down

0 comments on commit 6b11669

Please sign in to comment.