Skip to content

A simple, light-weight and strongly typed Command Line Parser made in .NET Standard!

License

Notifications You must be signed in to change notification settings

Storm-BE/CommandLineParser.Core

 
 

Repository files navigation

Buitld Status (AppVeyor) Open Issues Codecov Codefactor badge AGPL v3 NuGet badge

CommandLineParser

A simple, light-weight and strongly typed commandline parser made in .NET Standard!

Installation

PM> Install-Package MatthiWare.CommandLineParser

Quick Start

Example of configuring the port option using the Fluent API.

static void Main(string[] args)
{
   // create the parser
   var parser = new CommandLineParser<ServerOptions>();
   
   // configure the options using the Fluent API
   parser.Configure(options => options.Port)
      .Name("p", "port")
      .Description("The port of the server")
      .Required();

   // parse
   var parsed = parser.Parse(args);

   // check for parsing errors
   if (parsed.HasErrors)
   {
      Console.ReadKey();

      return -1;
   }

   Console.WriteLine($"Parsed port is {parsed.Result.Port}");
}

private class ServerOptions
{
   // options
   public int Port { get; set; }
}

Run command line

dotnet myapp --port 2551

For more advanced configuration options see the wiki.

About

A simple, light-weight and strongly typed Command Line Parser made in .NET Standard!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 94.3%
  • PowerShell 4.2%
  • Shell 1.5%