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
Type | Required | Position | PipelineInput |
---|---|---|---|
[Object] | true | 1 | true (ByValue) |
Width
Type | Required | Position | PipelineInput |
---|---|---|---|
[Int32] | false | 2 | false |
Syntax
Format-SpectreGrid [-Data] <Object> [[-Width] <Int32>] [<CommonParameters>]