Skip to content
ConsoleMonster

Show pass, warn and fail results

Print check results as status lines with a symbol, a colour and a detail per result, in PowerShell with New-ConsoleStatusList or in C# with StatusList.

A status list prints one line per result: the symbol and colour of its status, the name, then a detail in a muted column. Use it for checks, build steps or anything else that ends in pass, warn or fail.

Install-Module ConsoleMonster -Scope CurrentUser
PowerShellstatus-results.ps1
# Show check results as status lines: a symbol and colour per result, the name, then a detail.
Import-Module -Name ConsoleMonster

# Data: invented nightly checks; nothing is queried or changed.
$checks = @(
    [pscustomobject] @{ Name = 'Backups completed'; Result = 'Pass'; Note = '02:10 · 41 GB' }
    [pscustomobject] @{ Name = 'Certificates'; Result = 'Pass'; Note = 'next expiry in 64 days' }
    [pscustomobject] @{ Name = 'Disk space'; Result = 'Warn'; Note = 'sql01 at 81%' }
    [pscustomobject] @{ Name = 'Replication'; Result = 'Fail'; Note = 'dc02 last synced 3 h ago' }
    [pscustomobject] @{ Name = 'Patch window'; Result = 'Skip'; Note = 'not scheduled tonight' }
)

# Layout: one line per check. Label, Status and Detail are the properties the list reads.
$list = $checks | ForEach-Object {
    [pscustomobject] @{ Label = $_.Name; Status = $_.Result; Detail = $_.Note }
} | New-ConsoleStatusList

# Behaviour: print once.
$list | Show-Console
Full program
# Show check results as status lines: a symbol and colour per result, the name, then a detail.
Import-Module -Name ConsoleMonster

# Data: invented nightly checks; nothing is queried or changed.
$checks = @(
    [pscustomobject] @{ Name = 'Backups completed'; Result = 'Pass'; Note = '02:10 · 41 GB' }
    [pscustomobject] @{ Name = 'Certificates'; Result = 'Pass'; Note = 'next expiry in 64 days' }
    [pscustomobject] @{ Name = 'Disk space'; Result = 'Warn'; Note = 'sql01 at 81%' }
    [pscustomobject] @{ Name = 'Replication'; Result = 'Fail'; Note = 'dc02 last synced 3 h ago' }
    [pscustomobject] @{ Name = 'Patch window'; Result = 'Skip'; Note = 'not scheduled tonight' }
)

# Layout: one line per check. Label, Status and Detail are the properties the list reads.
$list = $checks | ForEach-Object {
    [pscustomobject] @{ Label = $_.Name; Status = $_.Result; Detail = $_.Note }
} | New-ConsoleStatusList

# Behaviour: print once.
$list | Show-Console

Run: ./status-results.ps1

Terminal
dotnet new console -n StatusResults
cd StatusResults
dotnet add package ConsoleMonster
C#Program.cs
// Show check results as status lines: a symbol and colour per result, the name, then a detail.
using ConsoleMonster;
using ConsoleMonster.Styling;
using ConsoleMonster.Widgets;

// Data: invented nightly checks; nothing is queried or changed.
var checks = new Check[]
{
    new("Backups completed", StatusKind.Pass, "02:10 · 41 GB"),
    new("Certificates", StatusKind.Pass, "next expiry in 64 days"),
    new("Disk space", StatusKind.Warn, "sql01 at 81%"),
    new("Replication", StatusKind.Fail, "dc02 last synced 3 h ago"),
    new("Patch window", StatusKind.Skip, "not scheduled tonight")
};

// Layout: one line per check, with its status and detail.
StatusList list = new StatusList();
foreach (var check in checks)
    list.Add(check.Name, check.Result, check.Note);

// Behaviour: print once.
Terminal.Write(list);

record Check(string Name, StatusKind Result, string Note);
Full program
// Show check results as status lines: a symbol and colour per result, the name, then a detail.
using ConsoleMonster;
using ConsoleMonster.Styling;
using ConsoleMonster.Widgets;

// Data: invented nightly checks; nothing is queried or changed.
var checks = new Check[]
{
    new("Backups completed", StatusKind.Pass, "02:10 · 41 GB"),
    new("Certificates", StatusKind.Pass, "next expiry in 64 days"),
    new("Disk space", StatusKind.Warn, "sql01 at 81%"),
    new("Replication", StatusKind.Fail, "dc02 last synced 3 h ago"),
    new("Patch window", StatusKind.Skip, "not scheduled tonight")
};

// Layout: one line per check, with its status and detail.
StatusList list = new StatusList();
foreach (var check in checks)
    list.Add(check.Name, check.Result, check.Note);

// Behaviour: print once.
Terminal.Write(list);

record Check(string Name, StatusKind Result, string Note);

Run: dotnet run

Terminal
dotnet new console -n StatusResults
cd StatusResults
dotnet add package ConsoleMonster
C# fluentProgram.cs
// Show check results as status lines: a symbol and colour per result, the name, then a detail.
using ConsoleMonster;
using ConsoleMonster.Styling;
using ConsoleMonster.Widgets;

// Data: invented nightly checks; nothing is queried or changed.
var checks = new Check[]
{
    new("Backups completed", StatusKind.Pass, "02:10 · 41 GB"),
    new("Certificates", StatusKind.Pass, "next expiry in 64 days"),
    new("Disk space", StatusKind.Warn, "sql01 at 81%"),
    new("Replication", StatusKind.Fail, "dc02 last synced 3 h ago"),
    new("Patch window", StatusKind.Skip, "not scheduled tonight")
};

// Layout: one line per check, with its status and detail.
StatusList list = Ui.StatusList();
foreach (var check in checks)
    list.Add(check.Name, check.Result, check.Note);

// Behaviour: print once.
list.Show();

record Check(string Name, StatusKind Result, string Note);
Full program
// Show check results as status lines: a symbol and colour per result, the name, then a detail.
using ConsoleMonster;
using ConsoleMonster.Styling;
using ConsoleMonster.Widgets;

// Data: invented nightly checks; nothing is queried or changed.
var checks = new Check[]
{
    new("Backups completed", StatusKind.Pass, "02:10 · 41 GB"),
    new("Certificates", StatusKind.Pass, "next expiry in 64 days"),
    new("Disk space", StatusKind.Warn, "sql01 at 81%"),
    new("Replication", StatusKind.Fail, "dc02 last synced 3 h ago"),
    new("Patch window", StatusKind.Skip, "not scheduled tonight")
};

// Layout: one line per check, with its status and detail.
StatusList list = Ui.StatusList();
foreach (var check in checks)
    list.Add(check.Name, check.Result, check.Note);

// Behaviour: print once.
list.Show();

record Check(string Name, StatusKind Result, string Note);

Run: dotnet run

Show-Console 80×524-bitFull

Five invented checks at 80 columns.

  • In PowerShell each item needs Label and Status, and may have Detail. Map your own property names with a ForEach-Object, as above, or pass an ordered hashtable of name = status with -InputObject.
  • The statuses include Pass, Warn, Fail, Skip, Info, Running and Pending, in any letter case. Each has its own symbol, so the list still reads in a terminal without colour.
  • In C#, StatusList.Add takes the label, a StatusKind and an optional detail.
  • To update the lines while work runs, give the list a -WidgetId and change items with Update-Console inside a dashboard, as in your first live dashboard.

Next

Edit this page on GitHub