Skip to content

Invoke-SpectreCommandWithStatus

Description

This function starts a Spectre status spinner with the specified title and spinner type, and invokes the specified script block. The spinner will continue to spin until the script block completes.
See https://spectreconsole.net/live/status for more information.


Examples

Example 1
This example demonstrates how to show a spinner while doing some work. Write-SpectreHost is used to update the host with progress without breaking the spinner animation.

$result = Invoke-SpectreCommandWithStatus -Spinner "Dots2" -Title "Showing a spinner..." -ScriptBlock {
    # Write updates to the host using Write-SpectreHost
    Start-Sleep -Seconds 1
    Write-SpectreHost "`n[grey]LOG:[/] Doing some work      "
    Start-Sleep -Seconds 1
    Write-SpectreHost "`n[grey]LOG:[/] Doing some more work "
    Start-Sleep -Seconds 1
    Write-SpectreHost "`n[grey]LOG:[/] Done                 "
    Start-Sleep -Seconds 1
    Write-SpectreHost " "
    return "Some result"
}
Write-SpectreHost "Result: $result"

Parameters

ScriptBlock

The script block to invoke.

TypeRequiredPositionPipelineInput
[ScriptBlock]true1false

Spinner

The type of spinner to display.

Valid Values:

  • Aesthetic
  • Arc
  • Arrow
  • Arrow2
  • Arrow3
  • Ascii
  • Balloon
  • Balloon2
  • BetaWave
  • Bounce
  • BouncingBall
  • BouncingBar
  • BoxBounce
  • BoxBounce2
  • Christmas
  • Circle
  • CircleHalves
  • CircleQuarters
  • Clock
  • Default
  • Dots
  • Dots10
  • Dots11
  • Dots12
  • Dots2
  • Dots3
  • Dots4
  • Dots5
  • Dots6
  • Dots7
  • Dots8
  • Dots8Bit
  • Dots9
  • Dqpb
  • Earth
  • Flip
  • Grenade
  • GrowHorizontal
  • GrowVertical
  • Hamburger
  • Hearts
  • Layer
  • Line
  • Line2
  • Material
  • Monkey
  • Moon
  • Noise
  • Pipe
  • Point
  • Pong
  • Runner
  • Shark
  • SimpleDots
  • SimpleDotsScrolling
  • Smiley
  • SquareCorners
  • Squish
  • Star
  • Star2
  • Toggle
  • Toggle10
  • Toggle11
  • Toggle12
  • Toggle13
  • Toggle2
  • Toggle3
  • Toggle4
  • Toggle5
  • Toggle6
  • Toggle7
  • Toggle8
  • Toggle9
  • Triangle
  • Weather
TypeRequiredPositionPipelineInput
[String]false2false

Title

The title to display above the spinner.

TypeRequiredPositionPipelineInput
[String]true3false

Color

The color of the spinner. Valid values can be found with Get-SpectreDemoColors.

TypeRequiredPositionPipelineInput
[Color]false4false

Syntax

Invoke-SpectreCommandWithStatus [-ScriptBlock] <ScriptBlock> [[-Spinner] <String>] [-Title] <String> [[-Color] <Color>] [<CommonParameters>]