MASES.CLIParser 3.1.2

.NET Standard 2.0
dotnet add package MASES.CLIParser --version 3.1.2
NuGet\Install-Package MASES.CLIParser -Version 3.1.2
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="MASES.CLIParser" Version="3.1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MASES.CLIParser --version 3.1.2
#r "nuget: MASES.CLIParser, 3.1.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install MASES.CLIParser as a Cake Addin
#addin nuget:?package=MASES.CLIParser&version=3.1.2

// Install MASES.CLIParser as a Cake Tool
#tool nuget:?package=MASES.CLIParser&version=3.1.2

CLI Parser

CI_BUILD CI_RELEASE

CLIParser
CLIParser nuget downloads

A library to manage command-line arguments in a simple way. It was an internal MASES project, now it is available to anyone.

This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to coc_reporting@masesgroup.com.

How it works

The library is very simple in its usage. The definition of command-line switches is based on generic C# types. The parser fully analyze the command line searching for switches and arguments. A special case is the one where the swithes can be inserted within an external file listing the switches line-by-line. To see a real application of the library look at project JCOReflectorCLI and JCOReflectorEngine

Argument definition

An argument can be defined using the following syntax sinppets:

arg = new ArgumentMetadata<bool>()
{
	Name = "test",
	ShortName = "tst",
	Help = "this is a test",
	Type = ArgumentType.Double,
	ValueType = ArgumentValueType.Free,
}

arg1 = new ArgumentMetadata<int>()
{
	Name = "range",
	Default = 9,
	Type = ArgumentType.Double,
	ValueType = ArgumentValueType.Range,
	MinValue = 2,
	MaxValue = 10,
}

Parser initialization

Upon arguments are defined they can be added to the list managed from the parser using:

Parser.Add(arg);

or the compact version:

arg1.Add();

Parser use

Then it is possible to use the parser on command-line arguments:

Parser.Parse(args);

or the compact version:

args.Parse();

Argument check

When the Parse method returns, a list of prepared arguments is available. The list can be used to get value or check for existence.

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 netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on MASES.CLIParser:

Package Downloads
MASES.JNet

JNet - .NET gateway for JVM APIs (Java, Scala, Kotlin, ...) to use .NET and JVM side-by-side

MASES.JCOReflectorEngine

JCOReflector Engine - JCOBridge based Java class generator that mimic .NET classes

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.1.2 309,201 4/6/2022
3.1.1 269 4/5/2022
3.1.0 184 4/4/2022
3.0.0 5,758 3/9/2022
2.2.1 1,111 1/6/2022
2.2.0 962 10/28/2021
2.1.2 791 10/8/2021
2.1.1 194 10/7/2021
2.1.0 185 10/6/2021
2.0.0 183 9/14/2021
1.1.0 307 8/31/2021