When building console applications that take parameters, you can use the arguments passed to Main(string[] args)
.
In the past I've simply indexed/looped that array and done a few regular expressions to extract the values. However, when the commands get more complicated, the parsing can get pretty ugly.
So I'm interested in:
- Libraries that you use
- Patterns that you use
Assume the commands always adhere to common standards such as answered here.
Please use the .net port of the apache commons cli API. This works great.
http://sourceforge.net/projects/dotnetcli/
and the original API for concepts and introduction
http://commons.apache.org/cli/
I would strongly suggest using NDesk.Options (Documentation) and/or Mono.Options (same API, different namespace). An example from the documentation: