mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 13:04:59 +02:00
Added comment-based help
This commit is contained in:
@ -1,23 +1,23 @@
|
||||
#!/snap/bin/powershell
|
||||
<#
|
||||
.SYNTAX ./write-typewriter.ps1 [<text>] [<speed>]
|
||||
.DESCRIPTION writes the given text with the typewriter effect
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
# Syntax: ./write-typewriter.ps1 [<text>]
|
||||
# Description: writes the given test with the typewriter effect
|
||||
# Author: Markus Fleschutz
|
||||
# Source: github.com/fleschutz/PowerShell
|
||||
# License: CC0
|
||||
param([string]$Text = "", [int]$Speed = 250) # in milliseconds
|
||||
|
||||
param([string]$Text)
|
||||
if ($Text -eq "" ) {
|
||||
$Text = "`nHello World`n-----------`nPowerShell is cross-platform`nPowerShell is open-source`nPowerShell is easy to learn`nPowerShell is fully documented`n`nThanks for watching`n`n:-)`n`n"
|
||||
}
|
||||
$Speed = 250 # milliseconds
|
||||
|
||||
try {
|
||||
$Random = New-Object System.Random
|
||||
|
||||
$Text -split '' | ForEach-Object {
|
||||
Write-Host -nonewline $_
|
||||
Start-Sleep -milliseconds $(1 + $Random.Next($Speed))
|
||||
write-host -nonewline $_
|
||||
start-sleep -milliseconds $(1 + $Random.Next($Speed))
|
||||
}
|
||||
exit 0
|
||||
} catch {
|
||||
|
Reference in New Issue
Block a user