Commanda 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Commanda --version 0.2.0
                    
NuGet\Install-Package Commanda -Version 0.2.0
                    
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="Commanda" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Commanda" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Commanda" />
                    
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 Commanda --version 0.2.0
                    
#r "nuget: Commanda, 0.2.0"
                    
#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 Commanda@0.2.0
                    
#: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=Commanda&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Commanda&version=0.2.0
                    
Install as a Cake Tool

Commanda

A lightweight, Cocona-like command line builder for .NET, combining System.CommandLine with the Generic Host (HostBuilder).

Supported target frameworks: net8.0, net9.0, net10.0.

Features

  • Fluent registration via IHostApplicationBuilder
  • Delegate-based command handlers (sync or async)
  • DI parameter injection for reference type parameters
  • Automatic binding of primitive/string parameters from CLI
  • Support for default help output from System.CommandLine

Quick Start

using Microsoft.Extensions.Hosting;
using Commanda;

var builder = Host.CreateApplicationBuilder(args);

builder.AddCommand("greet", "Say hello", (string name) =>
{
    Console.WriteLine($"Hello, {name}!");
});

builder.AddCommand("sum", (int a, int b) =>
{
    Console.WriteLine(a + b);
});

var app = builder.Build();
await app.RunCommandsAsync(args);

Run:

dotnet run --project examples/Commanda.Example -- greet Alice
dotnet run --project examples/Commanda.Example -- sum 2 5

Dependency Injection

Any non-primitive, non-string parameter will be resolved from the host service provider.

builder.Services.AddSingleton<GreetingService>();

builder.AddCommand("hello", (GreetingService svc) => svc.SayHello());

Installation (Future NuGet)

Planned package id: Commanda.

Versioning & Releases (Nerdbank.GitVersioning)

This repo uses Nerdbank.GitVersioning (NBGV) for SemVer and RC builds.

  • Base version is defined in version.json (e.g., 0.2.0).
  • RC builds are produced from tags like v0.2.0-rc.1, v0.2.0-rc.2, etc.
  • Stable releases are produced from tags like v0.2.0.

Typical flow:

  1. Tag an RC: git tag v0.2.0-rc.1 && git push origin v0.2.0-rc.1
  2. Build/package and publish RC to NuGet.
  3. After validation, tag stable: git tag v0.2.0 && git push origin v0.2.0
  4. Build/package and publish stable.

Roadmap / Future Enhancements

  • Attribute-based command & option metadata
  • Sub-commands via grouped classes
  • Validation (DataAnnotations)
  • Source generator for AOT friendliness
  • Middleware / pipeline hooks

License

MIT

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
0.3.0 81 1/17/2026
0.3.0-rc-0001 62 1/17/2026
0.2.0 97 1/17/2026