SquidStd.ConsoleCommands 0.41.2

dotnet add package SquidStd.ConsoleCommands --version 0.41.2
                    
NuGet\Install-Package SquidStd.ConsoleCommands -Version 0.41.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SquidStd.ConsoleCommands" Version="0.41.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SquidStd.ConsoleCommands" Version="0.41.2" />
                    
Directory.Packages.props
<PackageReference Include="SquidStd.ConsoleCommands" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SquidStd.ConsoleCommands --version 0.41.2
                    
#r "nuget: SquidStd.ConsoleCommands, 0.41.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SquidStd.ConsoleCommands@0.41.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SquidStd.ConsoleCommands&version=0.41.2
                    
Install as a Cake Addin
#tool nuget:?package=SquidStd.ConsoleCommands&version=0.41.2
                    
Install as a Cake Tool

<h1 align="center">SquidStd.ConsoleCommands</h1>

Interactive console commands for SquidStd hosts, rendered on a fixed prompt at the bottom of the terminal. A command registry supports aliases ("gc|collect"), quoted arguments, TAB autocomplete cycling, command history and an optional locked mode that ignores input until an unlock character is pressed. Log lines are rendered above the prompt through a Serilog sink, so the input row never gets torn by log output. When the console is not interactive (redirected output, CI), the input loop disables itself and commands remain callable programmatically.

Install

dotnet add package SquidStd.ConsoleCommands

Usage

using DryIoc;
using SquidStd.ConsoleCommands.Extensions;
using SquidStd.ConsoleCommands.Interfaces;

bootstrap.ConfigureServices(container =>
{
    container.RegisterCoreServices();
    container.AddConsoleCommands();               // prompt UI, command system, builtins, log sink
    container.RegisterGeneratedConsoleCommands(); // attribute-registered commands (source generated)

    return container;
});

await bootstrap.StartAsync();

// Delegate-based registration.
var commands = bootstrap.Resolve<ICommandSystemService>();
commands.RegisterCommand("echo", ctx =>
{
    ctx.WriteLine(string.Join(' ', ctx.Arguments));
    return Task.CompletedTask;
}, "Echoes the arguments back.");

// Programmatic execution (also works when the console is not interactive).
foreach (var line in await commands.ExecuteCommandWithOutputAsync("help"))
{
    Console.WriteLine(line);
}

Class-based commands are picked up by the SquidStd.Generators source generator: annotate an IConsoleCommandExecutor and call RegisterGeneratedConsoleCommands() (namespace SquidStd.Generators.ConsoleCommands). The class is registered as a singleton in the container and wired to the command system when it is resolved.

using SquidStd.ConsoleCommands.Attributes;
using SquidStd.ConsoleCommands.Data;
using SquidStd.ConsoleCommands.Interfaces;

[RegisterConsoleCommand("ping|p", "Replies pong.")]
internal sealed class PingCommand : IConsoleCommandExecutor
{
    public string Description => "Replies pong.";

    public Task ExecuteAsync(ConsoleCommandContext context)
    {
        context.WriteLine("pong");

        return Task.CompletedTask;
    }
}

The builtin commands help (?), clear (cls) and exit (quit) are registered by AddConsoleCommands(). exit requests a graceful shutdown through ISquidStdLifetime - with a RunAsync host the process stops its services in order and exits cleanly. With a manual StartAsync/StopAsync host, observe ISquidStdLifetime.ShutdownToken yourself - or just use RunAsync.

Configuration

The consoleCommands section of the SquidStd YAML config controls the prompt:

consoleCommands:
  Prompt: "myapp> "
  StartLocked: true
  UnlockCharacter: "*"

Set logger.EnableConsole: false so the prompt log sink replaces the standard console sink; otherwise every log line is written twice.

Key types

Type Purpose
ICommandSystemService Registry and dispatcher: register, execute, collect output, autocomplete.
ConsoleCommandContext Handler context: raw text, parsed arguments and the output writer.
IConsoleCommandExecutor Contract for class-based commands registered via the attribute.
RegisterConsoleCommandAttribute Marks an executor for source-generated registration (name/aliases + description).
ConsoleCommandsConfig consoleCommands config section: prompt text, locked start, unlock character.

License

MIT - part of SquidStd.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.41.2 88 9/1/2026
0.41.1 132 8/5/2026
0.41.0 103 7/24/2026
0.40.1 105 7/23/2026
0.40.0 98 7/21/2026
0.39.0 96 7/20/2026
0.38.0 99 7/20/2026
0.37.0 111 7/17/2026
0.36.0 107 7/15/2026
0.35.0 104 7/15/2026
0.34.0 108 7/14/2026
0.33.1 103 7/13/2026
0.33.0 99 7/13/2026
0.32.1 105 7/13/2026
0.32.0 102 7/13/2026
0.31.0 100 7/12/2026
0.30.0 99 7/12/2026
0.29.0 97 7/11/2026
0.28.0 104 7/8/2026
0.27.0 109 7/7/2026
Loading failed