A Net Core 3.1 library for parsing command line arguments in a flexible fashion.
Basic Usage
// create an instance of BindingTargetBuilder (here done via // dependency injection). Note that there are several objects // you need to create if you want to create an instance of // BindingTargetBuilder without dependency injection. var builder = ServiceProvider.GetRequiredService<BindingTargetBuilder>(); // configure the builder (these are the minimum calls you need to make) builder.Prefixes( "-", "--", "/" ) .Quotes( '\'', '"' ) .HelpKeys( "h", "?" ); var binder = builder.AutoBind<Program>(); if (binder == null) throw new NullReferenceException(nameof(Program)); binder.Options[ "i" ]!.SetValidator( OptionInRange<int>.GreaterThan( 0 ) ); if (!binder.Parse(args)) { Environment.ExitCode = 1; return; } Console.WriteLine($"IntValue is {IntValue}"); Console.WriteLine($"TextValue is {TextValue}"); Console.WriteLine(Unkeyed.Count == 0 ? "No unkeyed parameters" : $"Unkeyed parameters: {string.Join(", ", Unkeyed)}");
Available from nuget (see the project’s nuget page).
For more information refer to the project’s github page.