Cliargs.NET
1.3.0
dotnet add package Cliargs.NET --version 1.3.0
NuGet\Install-Package Cliargs.NET -Version 1.3.0
<PackageReference Include="Cliargs.NET" Version="1.3.0" />
paket add Cliargs.NET --version 1.3.0
#r "nuget: Cliargs.NET, 1.3.0"
// 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
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 Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. 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 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. |
.NET Core | netcoreapp3.1 is compatible. |
.NET Framework | net45 is compatible. net451 is compatible. net452 is compatible. net46 is compatible. net461 is compatible. net462 is compatible. net463 was computed. net47 is compatible. net471 is compatible. net472 is compatible. net48 is compatible. net481 was computed. |
-
.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.