Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssougnez/dc5030b013ef972a0ad47bfd8e070b99 to your computer and use it in GitHub Desktop.
Save ssougnez/dc5030b013ef972a0ad47bfd8e070b99 to your computer and use it in GitHub Desktop.
Function Error {
Param([string]$message)
return @{
Type = [ResultType]::Error
Message = $message
}
}
Function Success {
return @{
Type = [ResultType]::Success
}
}
Function Warning {
Param([string]$message)
return @{
Type = [ResultType]::Warning
Message = $message
}
}
Function HandleResult {
Param(
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[Hashtable]$result
)
Process {
if ($result.Type -eq [ResultType]::Success) {
Write-Host "Done!" -ForegroundColor Cyan
}
if ($result.Type -eq [ResultType]::Warning) {
Write-Host $result.Message -ForegroundColor Yellow
}
if ($result.Type -eq [ResultType]::Error) {
Write-Host $result.Message -ForegroundColor Red
throw "Deployment can't continue..."
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment