Skip to content

PowerShell Host Methods using Spectre.Console

License

Notifications You must be signed in to change notification settings

jborean93/PSGhost

Repository files navigation

PSGhost

Test workflow codecov License

Enable a PowerShell host implementation that uses Spectre.Console for host methods like progress updates and choice selection. This is a Proof of Concept module to see what is needed to utilise Spectre.Console in PowerShell.

See about_PSGhost for more details.

Requirements

These cmdlets have the following requirements

  • PowerShell v7.2 or newer

Examples

Here are a few examples where PSGhost changes the implementation for certain host functions. The scripts used to test these scenarios can be found in Examples.

Progress Records

A progress record with a percentage on builtin looks like

Builtin Progress Percentage

Note: The stray line at the top is an artifact of asciinema

This is PSGhost

PSGhost Progress Percentage

Note: The bar and spinner are incorrectly generated in asciinema.

A progress record may also not have an explicit percentage indicator but rather embed it in the status description. This is what this looks like on builtin

Builtin No Percentage

Note: The stray line at the top is an artifact of asciinema

This is PSGhost

PSGhost No Percentage

Note: The bar and spinner are incorrectly generated in asciinema.

Prompt For Choice

Here is what $host.UI.PromptForChoice looks like today

Builtin Choice

This is PSGhost

PSGhost Choice

It is also possible to have a prompt for multiple choices, this is the builtin version

Builtin Choices

This is PSGhost

PSGhost Choices

Confirm

When -Confirm is used, it will bring up the choice dialog box. This is what it looks like in builtin

Builtin Confirm

This is PSGhost

PSGhost Confirm

Installing

This module is meant to be a proof of concept and is not published to the PSGallery. To try it out you can build the module locally and import it. It requires the dotnet sdk to be available on the PATH.

pwsh -File build.ps1 -Configuration Debug -Task Build
Import-Module -Name ./output/PSGhost
Enable-PSGhost

Contributing

Contributing is quite easy, fork this repo and submit a pull request with the changes. To build this module run .\build.ps1 -Task Build in PowerShell. To test a build run .\build.ps1 -Task Test in PowerShell. This script will ensure all dependencies are installed before running the test suite.

About

PowerShell Host Methods using Spectre.Console

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published