Skip to content
ConsoleMonster

Help sections

Fold long help into sections, keep one open and widen the pane you are reading.

Demos Terminal apps

Use it when a reference page is too long to read at once and readers jump between sections.

  • Live
  • 88×22
  • PowerShell 7.4+
  • .NET 8.0+
Help sections 88×2224-bitFull

How it's built

The whole program in one file, with its sample data at the top. It drew the recording above; all three styles produce the same frame bytes.

PowerShellhelp-sections.ps1View on GitHub
# Fold help sections and resize the pane beside them.

Import-Module -Name ConsoleMonster
# All data is synthetic and inline; no services are contacted or changed.

# Layout: construct the widgets shown on screen.
$content = {
    New-ConsoleSplitter -Key Panes -Ratio 0.6 -Fill -First {
        New-ConsoleCollapsible -Accordion -Content {
            New-ConsoleCollapsible -Key Synopsis -Expanded -Content {
                'Lists servers and their roles from an inline inventory.'
            }
            New-ConsoleCollapsible -Key Parameters -Summary '(3)' -Content {
                '-Name    server name or wildcard'
                '-Role    web, db or cache'
                '-Online  only servers that answer'
            }
            New-ConsoleCollapsible -Key Examples -Summary '(2)' -Content {
                'Get-Inventory -Role web'
                'Get-Inventory -Name db* -Online'
            }
        }
    } -Second {
        New-ConsolePanel -Title Related -Content {
            'Get-Service'
            'Test-Connection'
        }
    }
}

# Behaviour: Enter folds a section, + expands all, Ctrl+Shift+Left/Right resizes; Escape exits.
Show-ConsoleApp -Content $content
C#Program.csView on GitHub
// Fold help sections and resize the pane beside them.
// All data is synthetic and inline; no services are contacted or changed.
using ConsoleMonster.Interactive;
using ConsoleMonster.Layout;
using ConsoleMonster.Widgets;

// Layout: construct the widgets shown on screen.
Splitter layout = new Splitter(
    new Accordion(
        new Collapsible(
            "Synopsis",
            new TextBlock("Lists servers and their roles from an inline inventory."))
        {
            Expanded = true
        },
        new Collapsible("Parameters", new Rows(
            new TextBlock("-Name    server name or wildcard"),
            new TextBlock("-Role    web, db or cache"),
            new TextBlock("-Online  only servers that answer")))
        {
            Summary = "(3)"
        },
        new Collapsible("Examples", new Rows(
            new TextBlock("Get-Inventory -Role web"),
            new TextBlock("Get-Inventory -Name db* -Online")))
        {
            Summary = "(2)"
        }),
    new Panel(new Rows(
        new TextBlock("Get-Service"),
        new TextBlock("Test-Connection"))) { Title = "Related" })
{
    Key = "Panes",
    Ratio = 0.6
};

// Behaviour: Enter folds a section, + expands all, Ctrl+Shift+Left/Right resizes; Escape exits.
ConsoleApp.Run(layout);
C# fluentProgram.Fluent.csView on GitHub
// Fold help sections and resize the pane beside them.
// All data is synthetic and inline; no services are contacted or changed.
using ConsoleMonster.Interactive;
using ConsoleMonster.Layout;
using ConsoleMonster.Widgets;
using ConsoleMonster;

// Layout: construct the widgets shown on screen.
Splitter layout = Ui.Splitter().First(Ui.Accordion().Content(c2 =>
{
    c2.Collapsible(collapsible => collapsible.Key("Synopsis")
        .Content(Ui.Markup("Lists servers and their roles from an inline inventory."))
        .Expanded());
    c2.Collapsible(collapsible => collapsible.Key("Parameters").Content(Ui.Rows().Content(c =>
    {
        c.Markup("-Name    server name or wildcard");
        c.Markup("-Role    web, db or cache");
        c.Markup("-Online  only servers that answer");
    })).Summary("(3)"));
    c2.Collapsible(collapsible => collapsible.Key("Examples").Content(Ui.Rows().Content(c =>
    {
        c.Markup("Get-Inventory -Role web");
        c.Markup("Get-Inventory -Name db* -Online");
    })).Summary("(2)"));
})).Second(Ui.Panel().Title("Related").Content(c2 =>
{
    c2.Rows(r => r.Content(c =>
    {
        c.Markup("Get-Service");
        c.Markup("Test-Connection");
    }));
})).Key("Panes").Ratio(0.6);

// Behaviour: Enter folds a section, + expands all, Ctrl+Shift+Left/Right resizes; Escape exits.
ConsoleApp.Run(layout);

Run it yourself

Three steps in PowerShell, four in C#. Every command copies with one click.

  1. Install the module

    Once. Windows PowerShell 5.1 or PowerShell 7 on Windows, macOS or Linux.

    Install-Module ConsoleMonster -Scope CurrentUser
  2. Save the program

    Download it, or copy it from above into help-sections.ps1.

  3. Run it

    From the folder you saved it in.

    ./help-sections.ps1
  1. Create a project

    A plain console app; .NET 8 or later.

    dotnet new console -n HelpSections; cd HelpSections
  2. Save the project

    The project selects one C# style at a time and restores ConsoleMonster.

  3. Save both programs

    Replace Program.cs and save Program.Fluent.cs beside it.

  4. Run it

    dotnet run
  1. Create a project

    A plain console app; .NET 8 or later.

    dotnet new console -n HelpSections; cd HelpSections
  2. Save the project

    The project selects one C# style at a time and restores ConsoleMonster.

  3. Save both programs

    Replace Program.cs and save Program.Fluent.cs beside it.

  4. Run it

    dotnet run --property:DemoStyle=Fluent

Or skip the copying. Run the bundled program.

Show-ConsoleDemo help-sections
$source = (Get-ConsoleDemo help-sections).Source
[IO.File]::WriteAllText("$PWD/help-sections.ps1", $source, [Text.UTF8Encoding]::new($true))

Make it yours

Start with these, then read the rest of the file.

  1. Replace the sections with your own command's help or a runbook.

  2. Start long sections such as Examples folded and give them a count.

  3. Put a list on the left and its details on the right of the splitter.

More terminal apps

All demos