Dignus.Commands 1.0.6

dotnet add package Dignus.Commands --version 1.0.6
                    
NuGet\Install-Package Dignus.Commands -Version 1.0.6
                    
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="Dignus.Commands" Version="1.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dignus.Commands" Version="1.0.6" />
                    
Directory.Packages.props
<PackageReference Include="Dignus.Commands" />
                    
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 Dignus.Commands --version 1.0.6
                    
#r "nuget: Dignus.Commands, 1.0.6"
                    
#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 Dignus.Commands@1.0.6
                    
#: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=Dignus.Commands&version=1.0.6
                    
Install as a Cake Addin
#tool nuget:?package=Dignus.Commands&version=1.0.6
                    
Install as a Cake Tool

Dignus.Commands

NuGet

Lightweight command execution system for local console and telnet remote control.

간단한 로컬 콘솔 명령 실행텔넷 기반 원격 명령 실행을 지원하는 커맨드 시스템입니다.

picture


Features / 특징

English

  • Attribute based command registration
  • Delegate based command registration
  • Async command execution
  • CancellationToken based cancellation
  • Middleware pipeline support
  • Local console command runner
  • Telnet remote command runner

Korean

  • Attribute 기반 커맨드 등록
  • Delegate 기반 커맨드 등록
  • 비동기 커맨드 실행
  • CancellationToken 기반 취소 지원
  • 미들웨어 파이프라인 지원
  • 로컬 콘솔 실행 지원
  • 텔넷 기반 원격 명령 실행

Quick Start

using Dignus.Commands;

var module = new LocalCommandRunner();

module.AddCommand<Close>();

module.Build();
module.Run();

Local Command Runner

Run commands directly from the local console.

로컬 콘솔에서 직접 명령을 입력받아 실행합니다.

using Dignus.Commands;

var module = new LocalCommandRunner();

module.AddCommand<Close>();

module.Build();
module.Run();

Telnet Command Runner

Start a telnet server and execute commands remotely.

텔넷 서버를 열고 외부 텔넷 클라이언트에서 접속하여 명령을 실행합니다.

using Dignus.Commands;

var module = new TelnetCommandRunner(port: 50000);

module.AddCommand<Close>();

module.Build();
module.Run();

Connect via telnet:

telnet 127.0.0.1 50000

Note

There is no dedicated telnet client module.
You connect using any telnet client.


Command Class

Create a command by implementing ICommand.

using Dignus.Commands.Attributes;
using Dignus.Commands.Interfaces;
using Dignus.Actor.Core;
using System.Diagnostics;

[Command("close")]
internal class Close : ICommand
{
    public Task InvokeAsync(string[] args, IActorRef sender, CancellationToken cancellationToken)
    {
        Process.GetCurrentProcess().Close();
        return Task.CompletedTask;
    }

    public string Print()
    {
        return "close process";
    }
}

Register the command

module.AddCommand<Close>();

Delegate Command

Commands can also be registered using delegates.

module.AddCommand("loop", "loop example", TestAsync);

async Task TestAsync(string[] args, IActorRef sender, CancellationToken cancellationToken)
{
    var count = 0;

    while (cancellationToken.IsCancellationRequested == false)
    {
        sender.Post(new CommandResponseMessage()
        {
            Content = $"sleep : {count++}"
        });

        await Task.Delay(2000, cancellationToken);
    }

    sender.Post(new CommandResponseMessage()
    {
        Content = $"end sleep : {count++}"
    });
}

Middleware

You can add middleware to the command execution pipeline.

module.AddMiddleware((ref CommandPipelineContext context, ref AsyncPipelineNext<CommandPipelineContext> next) =>
{
    var auth = context.Command.GetType().GetCustomAttribute<AuthAttribute>();

    if (auth.Execute(context) == false)
    {
        context.SenderActorRef.Post(new CommandResponseMessage()
        {
            Content = "invalid auth"
        });

        return Task.CompletedTask;
    }

    return next.InvokeAsync(ref context);
});

Command Execution Flow

User Input
     │
     ▼
Command Parser
     │
     ▼
Middleware Pipeline
     │
     ▼
Command Execution
     │
     ▼
CommandResponseMessage

Cancellation

Long running commands should support cancellation.

while (cancellationToken.IsCancellationRequested == false)
{
    await Task.Delay(1000, cancellationToken);
}

If a telnet connection closes, a CancelCommandMessage will be sent.


Output Message

Send output using CommandResponseMessage.

sender.Post(new CommandResponseMessage()
{
    Content = "hello"
});

Default Commands

Command Description
? show command list
Ctrl + C cancel running command

Module Lifecycle

var module = new LocalCommandRunner();

module.AddCommand<Close>();

module.Build();
module.Run();

Execution order

  1. Create module
  2. Register commands
  3. Register middleware
  4. Build()
  5. Run()

Run() must be called after Build().


Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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
1.0.6 0 3/19/2026
1.0.5 35 3/18/2026
1.0.4 119 3/15/2026
1.0.3 118 3/14/2026
1.0.2 124 3/11/2026
1.0.1 99 3/8/2026
1.0.0 96 3/8/2026