MASES.CLIParser
3.1.2
dotnet add package MASES.CLIParser --version 3.1.2
NuGet\Install-Package MASES.CLIParser -Version 3.1.2
<PackageReference Include="MASES.CLIParser" Version="3.1.2" />
paket add MASES.CLIParser --version 3.1.2
#r "nuget: MASES.CLIParser, 3.1.2"
// 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
CLIParser |
---|
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 net481 |
MonoAndroid | monoandroid |
MonoMac | monomac |
MonoTouch | monotouch |
Tizen | tizen40 tizen60 |
Xamarin.iOS | xamarinios |
Xamarin.Mac | xamarinmac |
Xamarin.TVOS | xamarintvos |
Xamarin.WatchOS | xamarinwatchos |
-
.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.