You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Matthias Beerens edited this page Aug 9, 2019
·
5 revisions
Quick Start
First of all you need to add the nuget package.
PM>Install-Package MatthiWare.CommandLineParser
Now you can setup the command line parser.
staticintMain(string[]args){// create the parservarparser=newCommandLineParser<ServerOptions>();// configure the options using the Fluent API (can also be done using attributes)parser.Configure(options =>options.Port).Name("p","port").Description("The port of the server").Required();// parsevarresult=parser.Parse(args);// check for parsing errors// By default errors and correct usage will be printed to the console// No need to print the errors ourselves if(result.HasErrors){Console.ReadKey();return-1;}Console.WriteLine($"Parsed port is {result.Result.Port}!");}