Skip to content
ConsoleMonster

Three ways to write it

Translate the same widgets between PowerShell parameters, C# initializers and C# fluent calls.

Every demo has three tabs: PowerShell | C# | C# fluent. They use the same widgets and operations. Choose the spelling that reads best, then use the other tabs to translate it. The choice follows you between pages; PowerShell is the default.

Try it

Install-Module ConsoleMonster -Scope CurrentUser
PowerShellobjects.ps1
$servers = @(
    [pscustomobject] @{ Name = 'web01'; Role = 'IIS'; Ram = 8GB; Status = 'Pass' }
    [pscustomobject] @{ Name = 'app01'; Role = 'App'; Ram = 16GB; Status = 'Warn' }
    [pscustomobject] @{ Name = 'db01'; Role = 'SQL'; Ram = 64GB; Status = 'Fail' }
)
$load = 12, 18, 31, 64, 47, 38, 55, 70, 72, 41
New-ConsoleRows -Gap 1 -Content {
    New-ConsoleColumns -Gap 1 -Content {
        New-ConsolePanel -Title 'Servers' -Content {
            $servers | New-ConsoleTable  -ShowTotals -Property @(
                @{ Name = 'Name'; Key = $true }
                'Role'
                @{ Name = 'Ram'; Presenter = 'Bytes' }
                @{ Name = 'Status'; Presenter = 'Status' }
            )
        }
        New-ConsolePanel -Title 'Summary' -Content {
            New-ConsoleRows -Content {
                New-ConsoleKeyValue -Content {
                    [pscustomobject] @{ Label = 'Servers'; Value = 3 }
                    [pscustomobject] @{ Label = 'Failed'; Value = 1 }
                }
                New-ConsoleChart -Type Sparkline -Title 'CPU' -InputObject $load
            }
        }
    }
    New-ConsoleText '[muted]Updated 10:02[/]'
} | Show-Console
Full program
Import-Module ConsoleMonster

$servers = @(
    [pscustomobject] @{ Name = 'web01'; Role = 'IIS'; Ram = 8GB; Status = 'Pass' }
    [pscustomobject] @{ Name = 'app01'; Role = 'App'; Ram = 16GB; Status = 'Warn' }
    [pscustomobject] @{ Name = 'db01'; Role = 'SQL'; Ram = 64GB; Status = 'Fail' }
)
$load = 12, 18, 31, 64, 47, 38, 55, 70, 72, 41
New-ConsoleRows -Gap 1 -Content {
    New-ConsoleColumns -Gap 1 -Content {
        New-ConsolePanel -Title 'Servers' -Content {
            $servers | New-ConsoleTable  -ShowTotals -Property @(
                @{ Name = 'Name'; Key = $true }
                'Role'
                @{ Name = 'Ram'; Presenter = 'Bytes' }
                @{ Name = 'Status'; Presenter = 'Status' }
            )
        }
        New-ConsolePanel -Title 'Summary' -Content {
            New-ConsoleRows -Content {
                New-ConsoleKeyValue -Content {
                    [pscustomobject] @{ Label = 'Servers'; Value = 3 }
                    [pscustomobject] @{ Label = 'Failed'; Value = 1 }
                }
                New-ConsoleChart -Type Sparkline -Title 'CPU' -InputObject $load
            }
        }
    }
    New-ConsoleText '[muted]Updated 10:02[/]'
} | Show-Console

Run: ./objects.ps1

Terminal
dotnet new console -n Servers
cd Servers
dotnet add package ConsoleMonster
C#Program.cs
Server[] servers = {
    new("web01", "IIS", 8L * 1024 * 1024 * 1024, StatusKind.Pass),
    new("app01", "App", 16L * 1024 * 1024 * 1024, StatusKind.Warn),
    new("db01", "SQL", 64L * 1024 * 1024 * 1024, StatusKind.Fail)
};
double[] load = { 12, 18, 31, 64, 47, 38, 55, 70, 72, 41 };

// Objects: each widget is a variable, set with properties and Add calls, then placed in the layout.
Table table = new Table { ShowTotals = true, AutoTotals = true };
table.Column(new TableColumn("Name") { IsKey = true });
table.Column(new TableColumn("Role"));
table.Column(new TableColumn("Ram") { Presenter = CellPresenters.Bytes });
table.Column(new TableColumn("Status"));
foreach (Server server in servers) {
    table.Values(server.Name, server.Role, server.Ram, server.Status);
}

KeyValueList summary = new KeyValueList();
summary.Value("Servers", 3);
summary.Value("Failed", 1);
Sparkline cpu = new Sparkline { Title = "CPU" };
cpu.Values(load);

Terminal.Write(new Rows(
    new Columns(
        new Panel(table, "Servers"),
        new Panel(new Rows(summary, cpu), "Summary")) { Gap = 1 },
    TextBlock.FromMarkup("[muted]Updated 10:02[/]")) { Gap = 1 });

record Server(string Name, string Role, long Ram, StatusKind Status);
Full program
using ConsoleMonster;
using ConsoleMonster.Layout;
using ConsoleMonster.Presenters;
using ConsoleMonster.Styling;
using ConsoleMonster.Widgets;

Server[] servers = {
    new("web01", "IIS", 8L * 1024 * 1024 * 1024, StatusKind.Pass),
    new("app01", "App", 16L * 1024 * 1024 * 1024, StatusKind.Warn),
    new("db01", "SQL", 64L * 1024 * 1024 * 1024, StatusKind.Fail)
};
double[] load = { 12, 18, 31, 64, 47, 38, 55, 70, 72, 41 };

// Objects: each widget is a variable, set with properties and Add calls, then placed in the layout.
Table table = new Table { ShowTotals = true, AutoTotals = true };
table.Column(new TableColumn("Name") { IsKey = true });
table.Column(new TableColumn("Role"));
table.Column(new TableColumn("Ram") { Presenter = CellPresenters.Bytes });
table.Column(new TableColumn("Status"));
foreach (Server server in servers) {
    table.Values(server.Name, server.Role, server.Ram, server.Status);
}

KeyValueList summary = new KeyValueList();
summary.Value("Servers", 3);
summary.Value("Failed", 1);
Sparkline cpu = new Sparkline { Title = "CPU" };
cpu.Values(load);

Terminal.Write(new Rows(
    new Columns(
        new Panel(table, "Servers"),
        new Panel(new Rows(summary, cpu), "Summary")) { Gap = 1 },
    TextBlock.FromMarkup("[muted]Updated 10:02[/]")) { Gap = 1 });

record Server(string Name, string Role, long Ram, StatusKind Status);

Run: dotnet run

Terminal
dotnet new console -n Servers
cd Servers
dotnet add package ConsoleMonster
C# fluentProgram.cs
Server[] servers = {
    new("web01", "IIS", 8L * 1024 * 1024 * 1024, StatusKind.Pass),
    new("app01", "App", 16L * 1024 * 1024 * 1024, StatusKind.Warn),
    new("db01", "SQL", 64L * 1024 * 1024 * 1024, StatusKind.Fail)
};
double[] load = { 12, 18, 31, 64, 47, 38, 55, 70, 72, 41 };

// Objects: each widget is a variable, set with properties and Add calls, then placed in the layout.
Table table = Ui.Table()
    .ShowTotals()
    .AutoTotals()
    .Column(new TableColumn("Name").Key())
    .Column(new TableColumn("Role"))
    .Column(new TableColumn("Ram").Presenter(CellPresenters.Bytes))
    .Column(new TableColumn("Status"));
foreach (Server server in servers) {
    table.Values(server.Name, server.Role, server.Ram, server.Status);
}

KeyValueList summary = Ui.KeyValue();
summary.Value("Servers", 3);
summary.Value("Failed", 1);
Sparkline cpu = Ui.Sparkline().Title("CPU").Values(load);
Ui.Rows().Gap(1).Content(rowsContent2 =>
{
    rowsContent2.Columns(columns => columns.Gap(1).Content(columnsContent =>
    {
        columnsContent.Panel(p => p.Title("Servers").Content(panelContent =>
        {
            panelContent.Add(table);
        }));
        columnsContent.Panel(p => p.Title("Summary").Content(panelContent =>
        {
            panelContent.Rows(r => r.Content(rowsContent =>
            {
                rowsContent.Add(summary);
                rowsContent.Add(cpu);
            }));
        }));
    }));
    rowsContent2.Markup("[muted]Updated 10:02[/]");
}).Show();

record Server(string Name, string Role, long Ram, StatusKind Status);
Full program
using ConsoleMonster;
using ConsoleMonster.Layout;
using ConsoleMonster.Presenters;
using ConsoleMonster.Styling;
using ConsoleMonster.Widgets;

Server[] servers = {
    new("web01", "IIS", 8L * 1024 * 1024 * 1024, StatusKind.Pass),
    new("app01", "App", 16L * 1024 * 1024 * 1024, StatusKind.Warn),
    new("db01", "SQL", 64L * 1024 * 1024 * 1024, StatusKind.Fail)
};
double[] load = { 12, 18, 31, 64, 47, 38, 55, 70, 72, 41 };

// Objects: each widget is a variable, set with properties and Add calls, then placed in the layout.
Table table = Ui.Table()
    .ShowTotals()
    .AutoTotals()
    .Column(new TableColumn("Name").Key())
    .Column(new TableColumn("Role"))
    .Column(new TableColumn("Ram").Presenter(CellPresenters.Bytes))
    .Column(new TableColumn("Status"));
foreach (Server server in servers) {
    table.Values(server.Name, server.Role, server.Ram, server.Status);
}

KeyValueList summary = Ui.KeyValue();
summary.Value("Servers", 3);
summary.Value("Failed", 1);
Sparkline cpu = Ui.Sparkline().Title("CPU").Values(load);
Ui.Rows().Gap(1).Content(rowsContent2 =>
{
    rowsContent2.Columns(columns => columns.Gap(1).Content(columnsContent =>
    {
        columnsContent.Panel(p => p.Title("Servers").Content(panelContent =>
        {
            panelContent.Add(table);
        }));
        columnsContent.Panel(p => p.Title("Summary").Content(panelContent =>
        {
            panelContent.Rows(r => r.Content(rowsContent =>
            {
                rowsContent.Add(summary);
                rowsContent.Add(cpu);
            }));
        }));
    }));
    rowsContent2.Markup("[muted]Updated 10:02[/]");
}).Show();

record Server(string Name, string Role, long Ram, StatusKind Status);

Run: dotnet run

Servers 88 columns24-bitFull

The same servers, summary and CPU history in three source styles.

Parameters become properties and methods

A parameter keeps its domain name: -Title 'Build' becomes Title = "Build" or .Title("Build"). Panel's -Border Rounded maps to Border = BoxStyle.Rounded and .Border(BoxStyle.Rounded); Table uses its own TableBorder enum with the same property name. Each demo's generated How it maps note names its actual owning members.

Callback properties use the verb they declare: .Run(callback) for Action, .Validate(...) for Validator, .ShowWhen(...) for VisibleWhen, .PreviewBy(...) for Preview. C# treats .Action(...) as invoking the delegate property, so a property-named extension cannot assign it; the verb assigns the callback and returns the same object without invoking it. The generated mapping notes show this exception for each affected parameter.

New-ConsolePanel -Title 'Build' -Border Rounded -Content {
    New-ConsoleText 'All checks passed'
} | Show-Console
var panel = new Panel {
    Title = "Build",
    Border = BoxStyle.Rounded,
    Content = new TextBlock("All checks passed")
};
Terminal.Write(panel);
Ui.Panel()
    .Title("Build")
    .Border(BoxStyle.Rounded)
    .Content(c => c.Text("All checks passed"))
    .Show();

The C# snippets use ConsoleMonster, ConsoleMonster.Layout, ConsoleMonster.Glyphs and ConsoleMonster.Widgets. .Content(widget) attaches an existing widget; .Content(c => …) builds nested content, like PowerShell's -Content { … }. Rows, Columns, Stack, LayoutGrid, Panel and dashboard regions use the same grammar.

A pipeline ending becomes a chain ending: | Show-Console maps to .Show(), and | Export-ConsoleFrame -Path ./build.svg -Format Svg maps to .Save("./build.svg"), with the format taken from the extension (or .Save(path, OutputFormat.Svg)). Save dispatches through the same registered format providers. Add ConsoleMonster.Markdown for Markdown display/export and ConsoleMonster.Graphics for raster formats; the core does not implement those formats.

PowerShell switches name the non-default behavior: -NoMouse maps to Mouse = false and .Mouse(false). Numeric -TimeoutSeconds 0.5 maps to Timeout = TimeSpan.FromSeconds(0.5) and .Timeout(TimeSpan.FromSeconds(0.5)). Constructor arguments, collection rows and host callbacks have explicit entries in the API parity map.

Choosing a style

Use initializers for several settings, named variables and rows filled in a loop. Use fluent calls when one expression makes the layout easier to follow. Both mutate the same object and return the same widget types. Configure a widget before starting a live session; once the session owns it, use its update API.

Fluent methods are generated at build time from public properties. They use no runtime reflection and retain the receiver's derived type. Immutable values such as TerminalProfile keep their copy semantics and With* methods. The fluent entry point is Ui: New-ConsolePanel maps to Ui.Panel(), and a nested panel maps to c.Panel(p => p.Title("Build").Content(...)). Factories start empty; named calls configure them. The initializer tab keeps new Panel(...). Text, rule titles, row collections and live identities are the documented primary-input exceptions. Chart/progress and kind-selected inputs use the same typed options and Build() factories as PowerShell; content builders materialize these definitions after their configuration lambda.

The gallery checks all three maintained programs across every recorded state. The API reference shows property and fluent configuration forms together; the parity contract lists host and C#-only exceptions.

Next

Edit this page on GitHub