Show-Variable.psm1

#!/usr/bin/env pwsh
# Dump-Variable.psm1
# PowerShell variable dumping to screen debug tool

# Only compile once per session
$Private:src = "./DumpNode.cs"
if (-not ([type]::GetType("DumpNode", $false))) {
    Add-Type `
        -Path           $Private:src `
        -ReferencedAssemblies @(
            "System.dll",
            "System.Linq.dll",
            "System.Console.dll",
            "System.Collections.dll",
            "System.Reflection.dll",
            "System.Diagnostics.Process.dll"
            "System.Text.RegularExpressions.dll"
            )
}


function Show-Variable {
  param (
    [Parameter(
      Position = 0,
      ValueFromPipeline=$true
    )]
    [object]$Object,
    [bool]$Color = $true
  )
  process {
    [Khooz.Show.Variable.DumpNode]::new($Object).PrintTree($Color)
  }
}


Export-ModuleMember -Function Show-Variable
Set-Alias -Name Dump-Variable -Value Show-Variable -Scope Global
Set-Alias -Name Dump-Tree -Value Show-Variable -Scope Global
Set-Alias -Name dvar -Value Show-Variable -Scope Global
Set-Alias -Name dtree -Value Show-Variable -Scope Global