-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46e54b3
commit a3372e8
Showing
6 changed files
with
39 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 1 addition & 23 deletions
24
PwshSpectreConsole/formatting/Spectre.Console.AnsiConsole.format.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,4 @@ | ||
# TODO - Ask @startautomating how this can be done better | ||
Write-FormatView -TypeName "Spectre.Console.Rendering.Renderable" -Action { | ||
# Work out if the current object is being piped to another command, there isn't access to the pipeline in the format view script block so it's using a janky regex workaround | ||
try { | ||
$line = $MyInvocation.Line | ||
$start = $MyInvocation.OffsetInLine | ||
$lineAfterOffset = $line.SubString($start, ($line.Length - $start)) | ||
$targetIsInPipeline = $lineAfterOffset | Select-String "^[^;]+?\|" | ||
$pipelineSegment = $lineAfterOffset | Select-String "^[^;]+?(;|$)" | Select-Object -ExpandProperty Matches -First 1 | Select-Object -ExpandProperty Value | ||
$targetIsPipedToSpectreFunction = $pipelineSegment -match ".*\|.*(Write|Format|Out)-Spectre.*" | ||
Write-Debug "Line: $line" | ||
Write-Debug "Start: $start" | ||
Write-Debug "Line after offset: $lineAfterOffset" | ||
Write-Debug "Target is in pipeline: $targetIsInPipeline" | ||
Write-Debug "Pipeline segment: $pipelineSegment" | ||
Write-Debug "Target is piped to Spectre function: $targetIsPipedToSpectreFunction" | ||
} catch { | ||
Write-Debug "Failed to discover pipeline state for Spectre.Console.Rendering.Renderable: $_" | ||
} | ||
|
||
if ($targetIsInPipeline -and -not $targetIsPipedToSpectreFunction) { | ||
$_ | ||
} else { | ||
$_ | Out-SpectreHost | ||
} | ||
$_ | Out-SpectreHost -CustomItemFormatter | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters