Merge pull request #9 from KevinMarquette/develop !deploy
Made format function more flexible
This commit is contained in:
@@ -9,42 +9,54 @@ function Format-Chronometer
|
||||
$resultes = Get-Chronometer -Path $script.fullname -ScriptBlock {Invoke-Pester C:\workspace\PSGraph}
|
||||
$results | Format-Chronometer -WarnAt 20 -ErrorAt 200
|
||||
#>
|
||||
[cmdletbinding()]
|
||||
[cmdletbinding(DefaultParameterSetName='Script')]
|
||||
param(
|
||||
# This is a MonitoredScript object from Get-Chronometer
|
||||
[Parameter(
|
||||
ValueFromPipeline=$true
|
||||
ValueFromPipeline=$true,
|
||||
ParameterSetName='Script'
|
||||
)]
|
||||
[MonitoredScript[]]
|
||||
$InputObject,
|
||||
|
||||
# This is a ScriptLine object from a MonitoredScript object
|
||||
[Parameter(
|
||||
ValueFromPipeline=$true,
|
||||
ParameterSetName='Line'
|
||||
)]
|
||||
[ScriptLine[]]
|
||||
$Line,
|
||||
|
||||
# If the average time of a command is more than this, the output is yellow
|
||||
[int]
|
||||
$WarningAt = 20,
|
||||
|
||||
#If the average time of a comamand is more than this, the output is red
|
||||
[int]
|
||||
$ErrorAt = 200
|
||||
$ErrorAt = 200,
|
||||
|
||||
# Forces the report to show scripts with no execution time
|
||||
[switch]
|
||||
$ShowAll
|
||||
)
|
||||
|
||||
begin {
|
||||
$green = @{ForgroundColor='green'}
|
||||
$grey = @{ForgroundColor='grey'}
|
||||
$yellow = @{ForgroundColor='grey'}
|
||||
$yellow = @{ForgroundColor='grey'}
|
||||
$yellow = @{ForgroundColor='grey'}
|
||||
}
|
||||
process
|
||||
{
|
||||
foreach($script in $InputObject)
|
||||
{
|
||||
Write-Host ''
|
||||
Write-Host "Script: $($script.Path)" -ForegroundColor Green
|
||||
Write-Host "Execution Time: $($script.ExecutionTime)" -ForegroundColor Green
|
||||
foreach($line in $script.line)
|
||||
if($script.ExecutionTime -ne [TimeSpan]::Zero -or $ShowAll)
|
||||
{
|
||||
Write-ScriptLine $line -WarningAt $WarningAt -ErrorAt $ErrorAt
|
||||
Write-Host ''
|
||||
Write-Host "Script: $($script.Path)" -ForegroundColor Green
|
||||
Write-Host "Execution Time: $($script.ExecutionTime)" -ForegroundColor Green
|
||||
|
||||
$script.line | Format-Chronometer -WarningAt $WarningAt -ErrorAt $ErrorAt
|
||||
}
|
||||
}
|
||||
|
||||
foreach($command in $Line)
|
||||
{
|
||||
Write-ScriptLine $command -WarningAt $WarningAt -ErrorAt $ErrorAt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user