In my search for a simple and elegant library for parsing command line in .Net, I found two new candidates:
First one provides a fluent API really simple to use (only one gotcha: there is two github repo owned by same person and only old one details how usage can be printed on console with the elegant SetupHelp). Already used in a production code.
Second one seems to cover more powerfull options. This library is a minimal application framework centerer around verb notion (even if a default verb can be defined). The parser is in charge of running your application through a:
where your class TheApp declare methods corresponding to each verb. Each method parameters are gathers from command line according to attributes.
You have, among other things, validation (predifined with attributes and custom with code), pre/post condition for verbs, key shortening for verb and parameters and custom types in external file using either json or xml format.
Looking at CLAP’s code, I have found an ingenious way to validate key/value parameters using SQL Expressions builtin .Net DataColumn.Expression (code is here). A DataTable is construct, a column is added for each parameter using its name and type and a single row is added to contain each value. In a small amount of line, you have expressions like “index1 > index2 AND index2 > 28”, “Name NOT LIKE ‘Test*'” or “Name NOT IN ‘Test1’,’Test2′” (parent-child relation referencing and aggregate functions are not usable but complete syntax is here).