Skip to content
ConsoleMonster

Show a settings summary

Show settings as aligned key and value pairs with New-ConsoleKeyValue or KeyValueList, inside a panel, with a status mark on any value.

A key and value list aligns the keys in a column and the values beside them. Use it for the header of a report, the settings a script runs with, or a summary of what it changed.

Install-Module ConsoleMonster -Scope CurrentUser
PowerShellsettings-summary.ps1
# Show a summary of settings as aligned key and value pairs in a panel.
Import-Module -Name ConsoleMonster

# Layout: an ordered hashtable gives plain pairs; objects with a Status add a mark to their value.
$summary = New-ConsolePanel -Title 'Deployment' -Content {
    $keyValueOptions = @{
        InputObject = [ordered] @{
            Application = 'Orders API'
            Version = '4.2.1'
            Environment = 'staging'
            Region = 'westeurope'
        }
        Content = {
            [pscustomobject] @{ Key = 'Health check'; Value = 'passing'; Status = 'Pass' }
            [pscustomobject] @{ Key = 'Migration'; Value = 'waiting for approval'; Status = 'Warn' }
        }
    }
    New-ConsoleKeyValue @keyValueOptions
}

# Behaviour: print once.
$summary | Show-Console
Full program
# Show a summary of settings as aligned key and value pairs in a panel.
Import-Module -Name ConsoleMonster

# Layout: an ordered hashtable gives plain pairs; objects with a Status add a mark to their value.
$summary = New-ConsolePanel -Title 'Deployment' -Content {
    $keyValueOptions = @{
        InputObject = [ordered] @{
            Application = 'Orders API'
            Version = '4.2.1'
            Environment = 'staging'
            Region = 'westeurope'
        }
        Content = {
            [pscustomobject] @{ Key = 'Health check'; Value = 'passing'; Status = 'Pass' }
            [pscustomobject] @{ Key = 'Migration'; Value = 'waiting for approval'; Status = 'Warn' }
        }
    }
    New-ConsoleKeyValue @keyValueOptions
}

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

Run: ./settings-summary.ps1

Terminal
dotnet new console -n DeploymentSummary
cd DeploymentSummary
dotnet add package ConsoleMonster
C#Program.cs
// Show a summary of settings as aligned key and value pairs in a panel.
using ConsoleMonster;
using ConsoleMonster.Layout;
using ConsoleMonster.Styling;
using ConsoleMonster.Widgets;

// Layout: plain pairs first; a status adds a mark to its value.
KeyValueList pairs = new KeyValueList()
    .Add("Application", "Orders API")
    .Add("Version", "4.2.1")
    .Add("Environment", "staging")
    .Add("Region", "westeurope")
    .Add("Health check", "passing", StatusKind.Pass)
    .Add("Migration", "waiting for approval", StatusKind.Warn);
Panel summary = new Panel(pairs, "Deployment");

// Behaviour: print once.
Terminal.Write(summary);
Full program
// Show a summary of settings as aligned key and value pairs in a panel.
using ConsoleMonster;
using ConsoleMonster.Layout;
using ConsoleMonster.Styling;
using ConsoleMonster.Widgets;

// Layout: plain pairs first; a status adds a mark to its value.
KeyValueList pairs = new KeyValueList()
    .Add("Application", "Orders API")
    .Add("Version", "4.2.1")
    .Add("Environment", "staging")
    .Add("Region", "westeurope")
    .Add("Health check", "passing", StatusKind.Pass)
    .Add("Migration", "waiting for approval", StatusKind.Warn);
Panel summary = new Panel(pairs, "Deployment");

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

Run: dotnet run

Terminal
dotnet new console -n DeploymentSummary
cd DeploymentSummary
dotnet add package ConsoleMonster
C# fluentProgram.cs
// Show a summary of settings as aligned key and value pairs in a panel.
using ConsoleMonster;
using ConsoleMonster.Layout;
using ConsoleMonster.Styling;
using ConsoleMonster.Widgets;

// Layout: plain pairs first; a status adds a mark to its value.
KeyValueList pairs = Ui.KeyValue()
    .Add("Application", "Orders API")
    .Add("Version", "4.2.1")
    .Add("Environment", "staging")
    .Add("Region", "westeurope")
    .Add("Health check", "passing", StatusKind.Pass)
    .Add("Migration", "waiting for approval", StatusKind.Warn);
Panel summary = Ui.Panel().Title("Deployment").Content(panelContent =>
{
    panelContent.Add(pairs);
});

// Behaviour: print once.
summary.Show();
Full program
// Show a summary of settings as aligned key and value pairs in a panel.
using ConsoleMonster;
using ConsoleMonster.Layout;
using ConsoleMonster.Styling;
using ConsoleMonster.Widgets;

// Layout: plain pairs first; a status adds a mark to its value.
KeyValueList pairs = Ui.KeyValue()
    .Add("Application", "Orders API")
    .Add("Version", "4.2.1")
    .Add("Environment", "staging")
    .Add("Region", "westeurope")
    .Add("Health check", "passing", StatusKind.Pass)
    .Add("Migration", "waiting for approval", StatusKind.Warn);
Panel summary = Ui.Panel().Title("Deployment").Content(panelContent =>
{
    panelContent.Add(pairs);
});

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

Run: dotnet run

Show-Console 80×824-bitFull

A deployment summary in a panel at 80 columns.

  • -InputObject takes an ordered hashtable of plain pairs. -Content adds objects with Key, Value and optionally Status, which puts a status mark before the value. Both can be used together, in that order.
  • A value can use markup when its object has Markup = $true, for example '1.4 [muted]→[/] [bold]2.0[/]'. In C# the value is always markup.
  • -Columns 2 lays the pairs out in two columns when the window is wide enough.
  • In C#, KeyValueList.Add takes the key, the value and an optional StatusKind. A Panel with a title frames it.

Next

Edit this page on GitHub