Possible Duplicate:
Best way to parse command line arguments in C#?
I’m looking for a library that can provide easy command parsing. Somthing similar to command line parsers would be fine. The trouble with a command line parser is getting the actual command and paring it to the options easily.
For instance I may want to turn on debugging. To do so I would want to do something like this.
debug on -f "c:\logs\debug file.txt"
If I wanted to turn on optimization I could do this.
optimize on
or
optimize off
While I might be able to get a standard command line parser to accomplish this, there would need to be a bit of preprocessing before actually using a standard command line parser. I’m really just looking for an elegant solution that won’t require tons of debugging.
On a side note, has anyone any recommendation using python in .NET?
Python has one built in called argparse Python argparser
And for C# you can use: C# Argparse
If I needed to write one myself, I’d start out by writing a stack-based language interpreter, and then it’ll be really easy to parse options. You’ll have written half the grammar just by writing the lexer.
Python is one of those things that when you add it to anything, it instantly becomes awesome. So you can only imagine what using Python with .NET would be like. Coming from personal experience, you can do a lot of work very quickly using IronPython. (Oh, and you can use the TPL (Task Parallelism Library) too.
Have fun!