Skip to content

Commit

Permalink
Fix progress/status not returning values because spectre console just…
Browse files Browse the repository at this point in the history
… returns task.complete instead of fromresult
  • Loading branch information
ShaunLawrie authored Dec 7, 2023
1 parent f6be726 commit 1773fe1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion PwshSpectreConsole/private/Start-AnsiConsoleProgress.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ function Start-AnsiConsoleProgress {
[Parameter(Mandatory)]
[scriptblock] $ScriptBlock
)
$resultVariableName = "AnsiConsoleProgressResult-$([guid]::NewGuid())"
New-Variable -Name $resultVariableName -Scope "Script"
[Spectre.Console.AnsiConsole]::Progress().Start({
param (
$ctx
)
& $ScriptBlock $ctx
Set-Variable -Name $resultVariableName -Value (& $ScriptBlock $ctx) -Scope "Script"
})
return Get-Variable -Name $resultVariableName -ValueOnly
}
5 changes: 4 additions & 1 deletion PwshSpectreConsole/private/Start-AnsiConsoleStatus.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ function Start-AnsiConsoleStatus {
[Parameter(Mandatory)]
[scriptblock] $ScriptBlock
)
$resultVariableName = "AnsiConsoleStatusResult-$([guid]::NewGuid())"
New-Variable -Name $resultVariableName -Scope "Script"
[Spectre.Console.AnsiConsole]::Status().Start($Title, {
param (
$ctx
)
$ctx.Spinner = $Spinner
$ctx.SpinnerStyle = $SpinnerStyle
& $ScriptBlock $ctx
Set-Variable -Name $resultVariableName -Value (& $ScriptBlock $ctx) -Scope "Script"
})
return Get-Variable -Name $resultVariableName -ValueOnly
}

0 comments on commit 1773fe1

Please sign in to comment.