Format-SpectreGrid
Description
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.
Examples
Example 1
This example demonstrates how to display a grid of rows using the Spectre Console module with a list of lists.
Format-SpectreGrid -Data @("hello", "I", "am"), @("a", "grid", "of"), @("rows", "using", "spectre")
Example 2
This example demonstrates how to display a grid of rows using the Spectre Console module with a list of New-SpectreGridRow
objects.
The New-SpectreGridRow
function is used to create the rows when you want to avoid array collapsing in PowerShell turning your rows into a single array of columns.
$rows = 4$cols = 6$gridRows = @()for ($row = 1; $row -le $rows; $row++) { $columns = @() for ($col = 1; $col -le $cols; $col++) { $columns += "Row $row, Col $col" | Format-SpectrePanel } $gridRows += New-SpectreGridRow $columns}
$gridRows | Format-SpectreGrid
Parameters
Data
The data to be displayed in the grid. This can be a list of lists or a list of New-SpectreGridRow
objects.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Object] | true | 1 | true (ByValue) |
Width
The width of the grid. If not specified, the grid width will be automatic.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Int32] | false | 2 | false |
Padding
The padding to apply to the grid items. The default is 1.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Int32] | false | 3 | false |
Syntax
Format-SpectreGrid [-Data] <Object> [[-Width] <Int32>] [[-Padding] <Int32>] [<CommonParameters>]