Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get-Coffee - An animated coffee cup in PowerShell
# Microsoft Windows Powershell Module Script
#
# Name: Get-Coffee
# Version: 0.1.0.0
# Date: 2018-06-20
# Author: MMillar
# https://github.com/mmillar-bolis
# http://www.bolis.com
#
# License:
# The BSD 3-Clause License
# Copyright (c) 2018, The Bolis Group
#
# Description:
# Prints an animated coffee cup. Steamy.
#
# The Strictmode setting determines what coding rules will be enforced for the
# script's scope, and anything beneath it. The "Latest" setting ignores shell
# versions, opting for the best (most strict) practices.
Set-StrictMode -Version Latest
# Each function block intended to be exported as a command-object should have
# a block of synopsis information. This can then be used by `Get-Help` as the
# short-form basis for man-like help text.
<#
.SYNOPSIS
Print an animated coffee cup. Steamy
.DESCRIPTION
Print an animated coffee cup. Steamy
.EXAMPLE
\\PS> Get-Coffee
#>
Function Get-Coffee {
[CmdletBinding(
SupportsShouldProcess=$true
)]
Param()
Begin{
$ContinueLoop = $true
Clear-Host
# Put cursor position value in easy to access variable
$CursorValX = $([Console]::CursorLeft)
$CursorValY = $([Console]::CursorTop)
# Get max console size and print 4 lines less than said size
[int]$OutputLines = (Get-Host).UI.RawUI.WindowSize.Height
[string]$CupSteam01 = @'
(
) (
___...(------)--....___
.-"" ) ( ""-.
.-'``'|-._ ) _.-|
/ .--.| `""---...........---""` |
/ / | |
| | | |
\ \ | |
`\ `\ | |
`\ `| |
_/ /\ /
(__/ \ /
_..---""` \ /``""---.._
.-' \ / '-.
: `-.__ __.-' :
: ) ""---...---"" ( :
'._ `"--...___...--"` _.'
\""--..__ __..--""/
'._ """----.....______.....----""" _.'
`""--..,,_____ _____,,..--""`
`"""----"""`
'@
[string]$CupSteam02 = @'
)
( )
___...)------(--....___
.-"" ( ) ""-.
.-'``'|-._ ( _.-|
/ .--.| `""---...........---""` |
/ / | |
| | | |
\ \ | |
`\ `\ | |
`\ `| |
_/ /\ /
(__/ \ /
_..---""` \ /``""---.._
.-' \ / '-.
: `-.__ __.-' :
: ) ""---...---"" ( :
'._ `"--...___...--"` _.'
\""--..__ __..--""/
'._ """----.....______.....----""" _.'
`""--..,,_____ _____,,..--""`
`"""----"""`
'@
$CupArray = @($CupSteam01, $CupSteam02)
}
Process{
While ($ContinueLoop) {
If ([console]::KeyAvailable) {
$InputKey = [System.Console]::ReadKey()
Switch ( $InputKey.key) {
q { $ContinueLoop = $false; Clear-Host }
}
} Else {
ForEach ($Cup in $CupArray) {
Write-Output $Cup
Start-Sleep -Seconds 1
[Console]::SetCursorPosition(${CursorValX},${CursorValY})
}
}
}
}
End{}
}
Get-Coffee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment