Skip to content

Get Started

Demo

PwshSpectreConsole includes an interactive demo of most of the available functionality. The demo shows code blocks above each example to demonstrate the functions available.

Start the interactive demo by running:

PS> Start-SpectreDemo

Animated demo of PwshSpectreConsole

Using Prompts

The easiest way to get started with PwshSpectreConsole is to create a select-list like the one shown on the homepage. If you have a list of items you want a user to choose from you can store them in an array and then pass it to Read-SpectreSelection to ask the user to choose one:

# Start by creating your list of items
$items = @("Red", "Green", "Blue")

# Ask the user what they want
$chosenItem = Read-SpectreSelection -Title "Select your favorite color" -Choices $items -Color "Green"

# Do something with the chosen item
Write-SpectreHost "Your chosen color is '$color'"

Example of a user being prompted with a select list:

But what if you wanted to ask the use what they want for something like a fruit smoothie? You can use Read-SpectreMultiSelection to ask them to choose multiple items from the list:

# Start by creating your list of items
$items = @("apple", "banana", "orange", "pear", "strawberry", "durian", "lemon")

# Ask the user what they want
$chosenItems = Read-SpectreMultiSelection -Title "Select your favourite fruits" -Choices $items

# Do something with the chosen item
Write-SpectreHost "Your favourite fruits are $($chosenItems -join ', ')"

Example of a user being prompted with a multi-select list:

More

  • Most Spectre console functions can render a special markup language allowing you to easily write content with different colored text and emoji https://spectreconsole.net/markup
  • For more information on how to use prompts and other Spectre Console interactions, see the command reference.