Skip to content

Write-SpectreRule

Description

The Write-SpectreRule function writes a Spectre horizontal-rule to the console with the specified title, alignment, and color. You can control the width of the rule by specifying either the Width or WidthPercent parameter.


Examples

Example 1
This example demonstrates how to write a rule to the console.

Terminal window
Write-SpectreRule -Title "My Rule" -Alignment Center -Color Yellow

Example 2
This example demonstrates how to write a rule with a specific width.

Terminal window
Write-SpectreRule -Title "Fixed Width Rule" -Width 40

Example 3
This example demonstrates how to write a rule with a width that’s a percentage of the console width.

Terminal window
Write-SpectreRule -Title "Half Width Rule" -WidthPercent 50 -Alignment Center

Example 4 This example demonstrates writing a rule by directly providing the title text.

Terminal window
Write-SpectreRule "Simple Rule Title"

Parameters

Title

The title of the rule.

TypeRequiredPositionPipelineInput
[String]false1true (ByValue)

Alignment

The alignment of the text in the rule. The default value is Left.

Valid Values:

  • Left
  • Right
  • Center
TypeRequiredPositionPipelineInput
[String]falsenamedfalse

Color

The color of the rule. The default value is the accent color of the script.

TypeRequiredPositionPipelineInput
[Color]falsenamedfalse

LineColor

The color of the rule’s line. The default value is the default value color of the script.

TypeRequiredPositionPipelineInput
[Color]falsenamedfalse

Width

The width of the rule in characters. If not specified, the rule will span the full width of the console. Cannot be used together with WidthPercent.

TypeRequiredPositionPipelineInput
[Int32]falsenamedfalse

WidthPercent

The width of the rule as a percentage of the console width. Value must be between 1 and 100. Cannot be used together with Width.

TypeRequiredPositionPipelineInput
[Int32]falsenamedfalse

PassThru

Returns the Spectre Rule object instead of writing it to the console.

TypeRequiredPositionPipelineInput
[Switch]falsenamedfalse

Syntax

Terminal window
Write-SpectreRule [[-Title] <String>] [-Alignment <String>] [-Color <Color>] [-LineColor <Color>] [-PassThru] [<CommonParameters>]
Terminal window
Write-SpectreRule [[-Title] <String>] [-Alignment <String>] [-Color <Color>] [-LineColor <Color>] [-WidthPercent <Int32>] [-PassThru] [<CommonParameters>]
Terminal window
Write-SpectreRule [[-Title] <String>] [-Alignment <String>] [-Color <Color>] [-LineColor <Color>] [-Width <Int32>] [-PassThru] [<CommonParameters>]