Add support for validation and custom types
Add some sort of hook or attribute to plug validation into the parser pipeline
similar some similar frameworks use attributes or factory registration to allow an entrypoint for custom validation and type mapping (DI support would be awesome as well ;) )
a typical and widely used usage scenario for this would be filesystem path validation and mapping to IO classes such as FileInfo / DirectoryInfo an seemingly easy way to to add this type of validation functionality would be to allow validation attributes that inherit from a validation base class or interface and run custom or pre-written code
some examples of validation provided in similar frameworks are
[FileExists]
[DirectoryExists]
[FileNotExists]
[DirectoryNotExists]
[RegExValidation]
Powerargs provides a special class called a Reviver for custom type mapping as well that the framework looks for to try and map values to a custom or complex type ie path string => FileInfo
It is very hard to find a framework that does all 3 of these well currently and make this library a go to framework for myself and many other developers i am sure
as CLP 2.x is still in beta and major rewrite phase i think now would be a good time to look at feature expansion as well to increase the power of this framework
IMHO this would be overkill and it destroys the single-responsibility-principle aspect of this library.
@stanislavromanov what if it was set up to allow you to plug in an existing validation library (e.g. FluentValidation) that's run after all parsing or after each argument is parsed? The validations mentioned in the OP would either be built in (but optional) or compiled to a separate nuget and you could always design your own.
@stanislavromanov, i agree and disagree with you on this, without some sort of validation mechanism or custom mapping mechanism it really limits what can be used as an argument ie : FileInfo DirectoryInfo mapping, DateTime , TimeSpan, DateTimeOffset , are a few examples for mapping , being able to validate path exists is a good example of a custom validation , or an argument is in specified range .. I don't think allowing business rules in your parsing pipeline violates SRP and is a quite common requirement and a feature of many libraries,
+1 from me.
If I have to do my own validation, not only do I need to write code for annoying things like parsing and regex matching, I also don't get the benefits of automatic help text display on parsing errors (including the text that explains exactly what went wrong in the parsing).
Python does this using the type= option. https://docs.python.org/2/library/argparse.html#type
this project is dead , and has moved to https://github.com/commandlineparser/commandline