Skip to content

Commit 6132292

Browse files
committed
Added write-headline.ps1
1 parent 2b4fb24 commit 6132292

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

scripts/write-headline.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<#
2+
.SYNOPSIS
3+
Writes text as headline
4+
.DESCRIPTION
5+
This PowerShell script writes the given text as a headline.
6+
.PARAMETER text
7+
Specifies the headline text
8+
.EXAMPLE
9+
PS> ./write-headline.ps1 "Hello World"
10+
11+
* Hello World *
12+
---------------
13+
.LINK
14+
https://github.com/fleschutz/PowerShell
15+
.NOTES
16+
Author: Markus Fleschutz | License: CC0
17+
#>
18+
19+
param([string]$text = "")
20+
try {
21+
if ($text -eq "") { $text = Read-Host "Enter the headline text" }
22+
23+
Write-Host "`n* $text *" -foregroundColor green
24+
[int]$len = $text.Length
25+
[string]$line = "----"
26+
for ([int]$i = 0; $i -lt $len; $i++) { $line += "-" }
27+
Write-Host "$line" -foregroundColor green
28+
exit 0 # success
29+
} catch {
30+
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
31+
exit 1
32+
}

0 commit comments

Comments
 (0)