Upgrading to v2
π Get the New Version
π₯ Breaking Changes
Out-SpectreHost
is required if you want to render an item without additional whitespace above and below the item:- To enable the new features, the way the console handles the default host output has changed. Version 2 uses powershell formatting to render Spectre Console objects. When rendered to the terminal PowerShell pads these with a blank line before and after the renderable item.
$data | Format-SpectrePanel | Out-SpectreHost
will force the object to be rendered without padding.
- To enable the new features, the way the console handles the default host output has changed. Version 2 uses powershell formatting to render Spectre Console objects. When rendered to the terminal PowerShell pads these with a blank line before and after the renderable item.
ποΈ Deprecations
Format-SpectreJson
has had parameters deprecated:-NoBorder
,-Border
,-Color
,-Title
,-Width
, and-Height
parameters no longer take any effect and will be removed in a future version.
To wrap the json in a border you can now pipe the output to Format-SpectrePanel e.g.Format-SpectreJson -Data $data | Format-SpectrePanel
π New Features
Renderables
Renderables are objects that can be rendered to the console. Most functions now return a renderable object instead of writing directly to the console host. This allows you to assign the output of a function to a variable and use it in other functions or redirect the output to a file. The renderable objects can also be used as inputs to other Spectre Console functions so you can build complex layouts.
Live Rendering
The Invoke-SpectreLive
function allows you to run a scriptblock and update a renderable item live in real-time. This allow you to build simple terminal user interfaces or live updating dashboards.
See the documentation for Invoke-SpectreLive
for more information and examples.
All New Commandlets
New commandlets to make this PowerShell library compatible with the rest of the Spectre.Console C# library:
Add-SpectreTableRow
- Add a row to an existing table.Format-SpectreAligned
- Set the alignment for an item inside a panel/layout.Format-SpectreColumns
- A method for rendering an array of items in automatically layed out columns.Format-SpectreRows
- Render an array of items in rows.Format-SpectreGrid
- Render an array of items in a grid.New-SpectreGridRow
- Create a new row for a grid from an array of columns.Format-SpectrePadded
- Surround an item with whitespace.Format-SpectreTextPath
- Render a file/folder path with syntax highlighting.Format-SpectreException
- Render an exception with syntax highlighting.Invoke-SpectreLive
- Run a scriptblock and update a renderable item live in real-time.New-SpectreLayout
- For rendering items in nested layouts.Get-SpectreDemoFeatures
- A demo of the features of Spectre.Console available in PwshSpectreConsole.
Updated Commandlets
Read-*
- Most βreadβ functions now accept a-TimeoutSeconds
parameter after which, null is returned.Write-*
- Most βwriteβ functions now have a-PassThru
switch parameter that will return the renderable object instead of writing it to the host immediately.
What about the Canvas Widget?
The canvas widget is the lonely remaining widget that doesnβt have a function to access it in this module. It is accessible enough that it doesnβt make sense to implement in PowerShell. If you need to use it you can use the C# library directly e.g.