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.
Write-SpectreRule -Title "My Rule" -Alignment Center -Color Yellow
Example 2
This example demonstrates how to write a rule with a specific width.
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.
Write-SpectreRule -Title "Half Width Rule" -WidthPercent 50 -Alignment Center
Example 4 This example demonstrates writing a rule by directly providing the title text.
Write-SpectreRule "Simple Rule Title"
Parameters
Title
The title of the rule.
Type | Required | Position | PipelineInput |
---|---|---|---|
[String] | false | 1 | true (ByValue) |
Alignment
The alignment of the text in the rule. The default value is Left.
Valid Values:
- Left
- Right
- Center
Type | Required | Position | PipelineInput |
---|---|---|---|
[String] | false | named | false |
Color
The color of the rule. The default value is the accent color of the script.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Color] | false | named | false |
LineColor
The color of the rule’s line. The default value is the default value color of the script.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Color] | false | named | false |
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.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Int32] | false | named | false |
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.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Int32] | false | named | false |
PassThru
Returns the Spectre Rule object instead of writing it to the console.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Switch] | false | named | false |
Syntax
Write-SpectreRule [[-Title] <String>] [-Alignment <String>] [-Color <Color>] [-LineColor <Color>] [-PassThru] [<CommonParameters>]
Write-SpectreRule [[-Title] <String>] [-Alignment <String>] [-Color <Color>] [-LineColor <Color>] [-WidthPercent <Int32>] [-PassThru] [<CommonParameters>]
Write-SpectreRule [[-Title] <String>] [-Alignment <String>] [-Color <Color>] [-LineColor <Color>] [-Width <Int32>] [-PassThru] [<CommonParameters>]