Commandment 2.0.0-beta

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

<div align="center"> <img width="384" src="./res/commandment.png" /> </div>

<br>

Commandment

Let there be a good command-line interface

Commandment provides fluent builder extension methods for the new System.CommandLine API

Add to your project

$> dotnet add package Commandment

Build a fluent and composable CLI

using System.CommandLine;
using Commandment;

// Create build a typed argument ...
Option<uint> fooOpt = new("--foo", "-f")
  .WithDescription("Foo")
  .NonZero() // ... with convenient numeric validation methods
  .Required();

enum MyEnum {
  Foo,
  Bar,
  Baz
}

// Create an option that takes a variant of `MyEnum` ...
Option<MyEnum> barOpt = new("--bar", "-b")
  .WithDescription("Bar")
  .ValidEnumVariant(ignoreCase: true, showVariantsOnError: true) // ... with configurable parsing and validation
  .Optional()
  .ZeroOrOneArg()
  .WithDefaultValue(MyEnum.Baz);

// Create an option that takes a string ...
Option<string> bazOpt = new("--baz", "-B")
  .WithDescription("Baz")
  .ValidFilePath() // ... with file/directory path validation
  .Required(true);

// Put it all together
RootCommand cli = new RootCommand("MyCLI")
  .AddOpt(fooOpt)
  .AddOpt(barOpt)
  .WithAsyncAction(async (result, cancelToken) => {
    await Task.CompletedTask;
    return 0;
  })
  .Parse()
  .Invoke();

Future plans:

  • Implement fluent extensions
  • Create tests
  • Create a reflection-based declarative builder API
    • Define attribute API for Command, Subcommand, and Option
    • Implement reflection-based builder
Product 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 is compatible.  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 was computed.  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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
2.0.0-beta1 201 8/7/2025
2.0.0-beta 363 8/6/2025 2.0.0-beta is deprecated because it has critical bugs.