I want to parse a set of command line arguments that look like:
-p[project file path] -s[name 1]=[value 1] ... -s[name n]=[value n]
Where there is exactly one project p
and any number of settings s
.
I have tried using NDesk.Options
var set = new OptionSet {
{ "p=", "the project file", v => { /* do stuff */ } },
{ "s=", "a setting", (m, v) => { /* do stuff */ } },
};
and this works well in most cases, but when value
is a file path (even quoted) the \
causes the parser to drop everything to right. I've hacked round this by overriding the parse method on my own OptionSet
class that I've inherited from NDesk.Options.OptionSet
, but I was wondering if there are any libraries that can handle this kind of functionality out of the box?
UPDATE
Sorry it wasn't the \
I think it is the :
anyway a set of failing examples is:
-sSetting=C:\Temp
-sSetting="C:\Temp"
-s"Setting=C:\Temp"
They all fail with OptionException Error: Found 3 option values when expecting 2.