Welcome to CLI Parser
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.
Project disclaimer
CLI Parser is a project, curated by MASES Group, can be supported by the open-source community.
Its primary scope is to support other, public or internal, MASES Group projects: open-source community and commercial entities can use it for their needs and support this project, moreover there are dedicated community and commercial subscription plans.
The repository code and releases may contain bugs, the release cycle depends from critical discovered issues and/or enhancement requested from this or other projects.
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.