Use a CSV/SSV-like syntax instead e.g. -D=Id1,Id2,Id3
or -D=Id1;Id2;Id
etc. Then use NDesk.Options to parse to a single combined result Id1,Id2,Id3
then with a .Split(',')
afterwards verify the length or count is 3 or print a usage message.
It should be easy enough to modify NDesk.Options - which is only a single file - to handle this for you by splitting the array internally and returning it.
I also had to do so for something like I think illegal empty options e.g. -
if I remember since I didn't like the default behavior. It has now become my preferred C# command-line option handler along with the following {--/}key=value
parser in C# (and in Python) with or without the leading options chars:
public static Dictionary<string, string> KVs2Dict(IEnumerable<string> args, Dictionary<string, string> defaults = null)
{
Dictionary<string, string> d = defaults ?? new Dictionary<string, string>();
foreach (string arg in args)
{
string s = arg.TrimStart(new[] { '-', '/' });
string[] sa = s.Split(new[] { '=' }, 1);
string k = sa[0].Trim('"');
if (s.Contains('='))
{
string v = sa[1].Trim('"');
d[k] = v;
}
else
d[k] = null;
}
return d;
}
Keep it simple: with this one you don't even need NDesk.Options for simple Apps.
And how easy would it be to add your multiple values? Easy: just add another conditional and return Dictionary<string, object> instead!