Cliargs.NET 1.3.0

.NET 5.0 .NET Core 3.1 .NET Framework 4.5
dotnet add package Cliargs.NET --version 1.3.0
NuGet\Install-Package Cliargs.NET -Version 1.3.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="Cliargs.NET" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Cliargs.NET --version 1.3.0
#r "nuget: Cliargs.NET, 1.3.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.
// Install Cliargs.NET as a Cake Addin
#addin nuget:?package=Cliargs.NET&version=1.3.0

// Install Cliargs.NET as a Cake Tool
#tool nuget:?package=Cliargs.NET&version=1.3.0

Cliargs.NET

Command Line Interface Arguments parser for dotnet

NuGet Badge License
.NET Test Coverage
image Build history

Knowledge base

More examples and documentation is on Cliargs.NET Knowledge base


Cliargs.NET is a dotnet library helps you to parse and use the Command Line Interface arguments in easy way.

The main goal of Cliargs.NET is to help C# developers reduce their programming time without dealing with all validations and casting of the user input.

Cliargs.NET makes all for you, all you have to do is write your Setup configuration in order to configure the Arguments container, then, from key and values parsing, to validation is automatically done on app startup.

Install

Package Manager

Install-Package Cliargs.NET

Dotnet CLI

dotnet add package Cliargs.NET

Quick comparison

In this example, you see the difference between managing the command line arguments by yourself, or by Cliargs.NET, for an application with two arguments:

Argument         type key short key Optional
User Name string --name -n no
User age uint --age -a yes

The objective is to display the following message in a console app:

Dear {user name}, you're {user age} years old!

Example of old school way: 😔

👉 Example on gist 👈

New way with Cliargs.NET 🤩

Create your Setup class and implement the Configure method to create your app arguments:

public class CliArgsSetup : ICliArgsSetup
{
    public void Configure(ICliArgsContainer container)
    {
        var nameArg = CliArg.New<string>("name")
            .AsRequired()
            .WithShortName("n");

        var ageArg = CliArg.New<uint>("age")
            .AsOptional()
            .WithShortName("a");

        container.Register(nameArg);
        container.Register(ageArg);
    }
}

Initialize the AppCliArgs instance by calling Initialize method at the begining of your app main method:

AppCliArgs.Initialize<CliArgsSetup>(new CustomFormat());

The finally start using the arguments values

var name = AppCliArgs.GetArgValue<string>("name");
if (AppCliArgs.IsSet("age"))
{
    var age = AppCliArgs.GetArgValue<uint>("age");
    Console.WriteLine($"Dear {name}, you're {age} years old.");
}
else
{
    Console.WriteLine($"Dear {name}, we don't know your age!");
}
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp3.1
.NET Framework net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48 net481
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.
  • .NETFramework 4.5.1

    • No dependencies.
  • .NETFramework 4.5.2

    • No dependencies.
  • .NETFramework 4.6

    • No dependencies.
  • .NETFramework 4.6.1

    • No dependencies.
  • .NETFramework 4.6.2

    • No dependencies.
  • .NETFramework 4.7

    • No dependencies.
  • .NETFramework 4.7.1

    • No dependencies.
  • .NETFramework 4.7.2

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.

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.3.0 309 4/2/2022
1.2.3 287 3/20/2022
1.0.1 300 2/23/2022