SquidStd.ConsoleCommands
0.41.2
dotnet add package SquidStd.ConsoleCommands --version 0.41.2
NuGet\Install-Package SquidStd.ConsoleCommands -Version 0.41.2
<PackageReference Include="SquidStd.ConsoleCommands" Version="0.41.2" />
<PackageVersion Include="SquidStd.ConsoleCommands" Version="0.41.2" />
<PackageReference Include="SquidStd.ConsoleCommands" />
paket add SquidStd.ConsoleCommands --version 0.41.2
#r "nuget: SquidStd.ConsoleCommands, 0.41.2"
#:package SquidStd.ConsoleCommands@0.41.2
#addin nuget:?package=SquidStd.ConsoleCommands&version=0.41.2
#tool nuget:?package=SquidStd.ConsoleCommands&version=0.41.2
<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. |
Related
- Docs: SquidStd.ConsoleCommands
- Docs: SquidStd.Services.Core
License
MIT - part of SquidStd.
| Product | Versions 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. |
-
net10.0
- DryIoc.dll (>= 5.4.3)
- Serilog (>= 4.4.0)
- Spectre.Console (>= 0.57.2)
- SquidStd.Abstractions (>= 0.41.2)
- SquidStd.Core (>= 0.41.2)
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 |