Commands.NET
2.0.0-alpha.4
See the version list below for details.
dotnet add package Commands.NET --version 2.0.0-alpha.4
NuGet\Install-Package Commands.NET -Version 2.0.0-alpha.4
<PackageReference Include="Commands.NET" Version="2.0.0-alpha.4" />
<PackageVersion Include="Commands.NET" Version="2.0.0-alpha.4" />
<PackageReference Include="Commands.NET" />
paket add Commands.NET --version 2.0.0-alpha.4
#r "nuget: Commands.NET, 2.0.0-alpha.4"
#:package Commands.NET@2.0.0-alpha.4
#addin nuget:?package=Commands.NET&version=2.0.0-alpha.4&prerelease
#tool nuget:?package=Commands.NET&version=2.0.0-alpha.4&prerelease

Commands.NET
Consider leaving a ⭐
Do more, with less. With speed, compatibility and fluent integration in mind.
Commands.NET aims to improve your experience integrating input from different sources* into the same, concurrent pool and treating them as triggered actions, called commands. It provides a modular and intuitive API for registering and executing commands.
Browse the wiki for a full overview of the library.
*Sources can range from command-line, console, chatboxes, to social platforms like Discord, Slack, Messenger & much, much more.
Usage
Running a Command
A command is a method executed when a specific syntax is provided. By creating a manager to contain said command, you can run it with the provided arguments.
using Commands;
var command = Command.Create(() => "Hello world!", "greet");
var manager = ComponentManager.Create(command);
manager.TryExecute(new ConsoleContext(), args);
// dotnet run greet -> Hello world!
Creating Command Groups
Command groups are named collections of commands or other command groups. Groups allow for subcommand creation, where the group name is a category for its children.
using Commands;
var mathCommands = CommandGroup.Create("math");
mathCommands.AddRange(
Command.Create((double number, int sumBy) => number + sumBy,
"sum", "add"),
Command.Create((double number, int subtractBy) => number - subtractBy,
"subtract", "sub"),
Command.Create((double number, int multiplyBy) => number * multiplyBy,
"multiply", "mul"),
Command.Create((double number, int divideBy) => number / divideBy,
"divide", "div")
);
var manager = ComponentManager.Create(mathCommands);
manager.TryExecute(new ConsoleContext(), args);
// dotnet run math sum 5 3 -> 8
Creating Command Modules
Command modules are classes that can contain commands or nested command modules, which themselves can also contain (sub)commands.
using Commands;
public class HelpModule : CommandModule
{
[Name("help")]
public void Help()
{
var builder = new StringBuilder()
.AppendLine("Commands:");
foreach (var command in Manager!.GetCommands())
builder.AppendLine(command.GetFullName());
Respond(builder.ToString());
}
}
...
var helpCommands = CommandGroup.Create<HelpModule>();
var manager = ComponentManager.Create(mathCommands, helpCommands);
manager.TryExecute(new ConsoleContext(), args);
// dotnet run help -> Commands: math sum <...> math subtract <...> math ...
Using Dependency Injection
Commands.NET is designed to be compatible with dependency injection out of the box, propagating IServiceProvider throughout the execution flow.
using Commands;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection()
.AddSingleton<MyService>()
.AddSingleton<ComponentManager>(ComponentManager.Create(mathCommands, helpCommands);
.BuildServiceProvider();
var manager = services.GetRequiredService<ComponentManager>();
manager.TryExecute(new ConsoleContext(), args, new CommandOptions() { Services = services });
Modules can be injected directly from the provider. They themselves are considered transient services;
public class ServicedModule(MyService service) : CommandModule
{
}
Samples
- Commands.Samples.Core
- Manage, create and execute commands in a basic console application.
- Commands.Samples.Console
- Fluent API's, complex execution flow and workflow expansion.
- Commands.Samples.Hosting
- Integrating Commands.NET into the .NET Generic Host infrastructure.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Threading.Tasks.Extensions (>= 4.6.0)
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Commands.NET:
| Package | Downloads |
|---|---|
|
Commands.NET.Hosting
A package containing tooling for integrating Commands.NET with Microsoft.Extensions.*. |
|
|
Commands.NET.Console
An extension for Commands.NET that specifically aims to support the console and CLI, implementing Spectre.Console for beautification. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0-alpha.27 | 84 | 9/12/2025 |
| 2.0.0-alpha.26 | 137 | 9/4/2025 |
| 2.0.0-alpha.25 | 132 | 9/3/2025 |
| 2.0.0-alpha.24 | 133 | 9/3/2025 |
| 2.0.0-alpha.23 | 128 | 9/2/2025 |
| 2.0.0-alpha.22 | 166 | 8/8/2025 |
| 2.0.0-alpha.21 | 84 | 6/21/2025 |
| 2.0.0-alpha.20 | 57 | 6/21/2025 |
| 2.0.0-alpha.19 | 134 | 5/27/2025 |
| 2.0.0-alpha.18 | 130 | 5/26/2025 |
| 2.0.0-alpha.17 | 64 | 5/23/2025 |
| 2.0.0-alpha.16 | 131 | 5/22/2025 |
| 2.0.0-alpha.15 | 89 | 4/25/2025 |
| 2.0.0-alpha.14 | 121 | 4/25/2025 |
| 2.0.0-alpha.13 | 154 | 4/22/2025 |
| 2.0.0-alpha.12 | 156 | 4/22/2025 |
| 2.0.0-alpha.11 | 94 | 2/5/2025 |
| 2.0.0-alpha.10 | 83 | 1/30/2025 |
| 2.0.0-alpha.9 | 73 | 1/27/2025 |
| 2.0.0-alpha.8 | 84 | 1/27/2025 |
| 2.0.0-alpha.7 | 79 | 1/22/2025 |
| 2.0.0-alpha.6 | 73 | 1/16/2025 |
| 2.0.0-alpha.5 | 73 | 1/11/2025 |
| 2.0.0-alpha.4 | 78 | 1/9/2025 |
| 2.0.0-alpha.3 | 63 | 1/9/2025 |
| 2.0.0-alpha.2 | 89 | 1/7/2025 |
| 2.0.0-alpha.1 | 76 | 1/7/2025 |
| 1.0.0 | 266 | 12/2/2024 |
| 1.0.0-rc6 | 194 | 11/21/2024 |
| 1.0.0-rc5 | 182 | 11/19/2024 |
| 1.0.0-rc4 | 172 | 11/16/2024 |
| 1.0.0-rc3 | 172 | 11/16/2024 |
| 1.0.0-rc2 | 173 | 11/15/2024 |
| 1.0.0-rc1 | 168 | 11/15/2024 |
| 1.0.0-alpha9 | 162 | 11/2/2024 |
| 1.0.0-alpha8 | 150 | 10/21/2024 |
| 1.0.0-alpha7 | 365 | 10/16/2024 |
| 1.0.0-alpha6 | 182 | 5/22/2024 |
| 1.0.0-alpha5 | 178 | 4/14/2024 |
| 1.0.0-alpha4 | 152 | 2/15/2024 |
| 1.0.0-alpha3 | 137 | 2/14/2024 |
| 1.0.0-alpha2 | 156 | 2/10/2024 |
| 1.0.0-alpha1 | 153 | 2/8/2024 |
| 1.0.0-alpha | 158 | 2/6/2024 |