AtleX.CommandLineArguments is a helper library to facilitate parsing command line arguments into a strongly-typed object. Values can be validated with extensible and customisable validators and the library can automatically generate help for the user.
Supported .NET frameworks:
- .NET 4.6.1
- NETSTANDARD 2.0
AtleX.CommandLineArguments is available as NuGet package:
install-package AtleX.CommandLineArguments -Pre
See the Wiki for documentation. Use Getting started to get going.
public class Program
{
private class MyArgumentsClass : Arguments
{
[Required]
[Display(Description = "This text will be displayed in the help, when requested")]
public bool Argument1
{
get;
set;
}
[Display(Description = "This text will be displayed in the help, when requested")]
public string Name // Not required
{
get;
set;
}
}
static void Main(string[] args)
{
MyArgumentsClass cliArguments;
if (!CommandLineArguments.TryParse<MyArgumentsClass>(args, out cliArguments))
{
// Something wrong, exit or display help?
CommandLineArguments.DisplayHelp(cliArguments);
return;
}
if (cliArguments.Argument1)
{
}
}
}
AtleX.CommandLineArguments uses the MIT license, see the LICENSE file.