CommandLineUtils
CommandLineUtils is a library which helps developers implement command line applications in .NET. The primary goal of the library is to assist with parsing command line arguments and executing the correct commands related to those arguments. The library also provides various other utilities such as input helpers.
Tutorials to create your first .NET command line application, and docs on how to use the library.
Read the API documentation for this library.
View sample projects which use CommandLineUtils.
The project is open-source on GitHub.
See the latest releases of this library as a NuGet package.
Read notes about fixes and enhancements per release.
Using this library, you can write a command line application without doing the heavy lifting to support automated help text generation, masking input for passwords, parsing argument syntax, validation, etc.
using McMaster.Extensions.CommandLineUtils;
using System;
using System.ComponentModel.DataAnnotations;
class Program
{
public static int Main(string[] args) => CommandLineApplication.Execute<Program>(args);
[Option("-n")]
[Range(0, 10)]
[Required]
public int Count { get; }
public void OnExecute()
{
for (var i = 0; i < Count; i ++)
{
Prompt.GetPassword("Enter your password: ");
}
}
}