Skip to content

About

Console rendering for .NET and PowerShell: tables, trees, panels, charts and live dashboards, with no package dependencies. Runs on Windows PowerShell 5.1 and PowerShell 7.

Topics

Resources

Contributing

Stars

29 stars

Watchers

2 watching

Forks

Latest commit

 

History

274 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ConsoleMonster

Everyday output in one line. The monster when you need it. ConsoleMonster makes the output of the commands you already run readable, and draws tables, trees, charts, live runs, dashboards, menus and forms when you need more. One engine for PowerShell 5.1 and 7 and .NET, with no package dependencies and plain lines when the output is a log.

A live assessment dashboard: progress per target, a results summary, charts, failures by category and the log

Website · Documentation · Widgets · Prompts, menus and forms · .NET API · PowerShell commands

Install

Install-Module ConsoleMonster -Scope CurrentUser
dotnet new console -n FirstTable
cd FirstTable
dotnet add package ConsoleMonster

Nicer default output in one line

Files, processes, services, hashtables and more read as tables and records; the objects, pipelines, files and transcripts stay PowerShell's.

Enable-ConsoleFormatting
Get-ChildItem and a hashtable after Enable-ConsoleFormatting

To keep it in every session, add the lines -ProfileSnippet prints to your profile:

if (-not (Test-Path -Path $PROFILE)) {
    $null = New-Item -ItemType File -Path $PROFILE -Force
}
Enable-ConsoleFormatting -Feature All -ProfileSnippet | Add-Content -Path $PROFILE

Everyday PowerShell output

Tables, lists and trees

Format-ConsoleTable, Format-ConsoleList and Format-ConsoleTree take pipeline input and fit the window. Format-Table, Format-List and Format-Wide stay PowerShell's own unless you turn on -Feature FormatCommands.

Import-Module ConsoleMonster

# A few of PowerShell's own files, grouped by extension.
Get-ChildItem -Path $PSHOME -File |
    Where-Object Extension -in '.exe', '.json', '.ps1' |
    Format-ConsoleTable -Property Name, Length, LastWriteTime -GroupBy Extension
The files in PowerShell's folder grouped by extension, with sizes and dates

Coming from Format-Table · Tables at six widths

Widgets

Every widget is a New-Console* command: panels, trees, charts, logs, lanes and more. Containers take a script block of children, and items share -Status, -Detail and -Tone.

Import-Module ConsoleMonster

New-ConsoleBarChart -Tone Fail ([ordered] @{
    'Domain controllers' = 14
    'Group Policy'       = 9
    'Kerberos'           = 6
    'DNS'                = 4
    'PKI'                = 2
}) | Write-ConsoleWidget
A bar chart of failures by category

The widget gallery: every widget at every colour and glyph tier, in PowerShell and C#.

Live progress for long-running work

Import-Module ConsoleMonster

# Forty servers, eight at a time: three fail and one hangs past the four-second limit.
$servers = 1..40 | ForEach-Object { 'web{0:d2}' -f $_ }
$run = @{ Parallel = $true; ThrottleLimit = 8; TimeoutSeconds = 4; Title = 'Patching' }
$results = $servers | ForEach-ConsoleItem @run -ErrorAction SilentlyContinue {
    Start-Sleep -Milliseconds (500 + ([int] $_.Substring(3) * 137) % 900)
    if ($_ -in 'web13', 'web26', 'web39') { throw "$_ did not come back" }
    if ($_ -eq 'web22') { Start-Sleep -Seconds 10 }
    "$_ patched"
}
A parallel run of forty servers: the summary bar, a cell per server and the failures

Live runs · Live dashboards

C# and the fluent API

The same engine as a .NET library. Every widget has fluent With... and Add... methods, object initializers and Ui factories.

using ConsoleMonster;
using ConsoleMonster.Styling;
using ConsoleMonster.Widgets;

Terminal.Write(new StatusList()
    .Add("Restore NuGet packages", StatusKind.Pass, "1.6 s")
    .Add("Compile ConsoleMonster", StatusKind.Pass, "4.7 s")
    .Add("Run Pester on PowerShell 7", StatusKind.Warn, "1 skipped")
    .Add("Sign module files", StatusKind.Skip, "skipped")
    .Add("Pack ConsoleMonster.2.0.0.nupkg", StatusKind.Running)
    .Add("Publish to PowerShell Gallery", StatusKind.Pending));
A status list of build steps: passed, warning, skipped, running and pending

Three ways to write it in C# · Logging · Hosting dashboard · dotnet new template

Save, replay and test

Views export to Markdown, HTML, SVG and text, live runs record and replay, and Assert-ConsoleOutput checks output in tests.

Import-Module ConsoleMonster

# The largest files in PowerShell's folder, as a Markdown table for a report.
Get-ChildItem -Path $PSHOME -File |
    Sort-Object -Property Length -Descending |
    Select-Object -First 5 |
    Format-ConsoleTable -Property Name, Length, LastWriteTime -As Markdown
The Markdown table the script printed

Recording and replay · Testing your output

Thread safety

Any thread can update the screen and one thread draws it, so parallel work never tears the view.

Import-Module ConsoleMonster

$dashboard = New-ConsoleDashboard -Title 'Workers' {
    New-ConsolePanel -Title 'Log' -Fill { New-ConsoleLog }
}
1..8 | Start-ConsoleDashboard $dashboard -Parallel -ThrottleLimit 8 {
    param($Number)
    Start-Sleep -Milliseconds (Get-Random -Maximum 800)
    Write-Host "worker $Number finished"
}

Threads and concurrency: what is safe from which thread, and the stress test.

Compatibility

  • PowerShell 5.1 and 7. On 5.1 one ConsoleMonster version loads per session; restart it after an upgrade.
  • .NET netstandard2.0, net472, net8.0 and net10.0, no package dependencies, AOT compatible on net8.0 and net10.0 (trimming notes).
  • Consoles are detected (colour, glyphs, size, CI, redirection); NO_COLOR and CONSOLEMONSTER_* override it (hosts and CI, upgrading from 0.0.x).

Benchmarks · Changelog · Contributing · MIT license · Maintained by Evotec.

About

Console rendering for .NET and PowerShell: tables, trees, panels, charts and live dashboards, with no package dependencies. Runs on Windows PowerShell 5.1 and PowerShell 7.

Topics

Resources

Contributing

Stars

29 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages