Hello
For my project I get better results with these two
changes in private void Nini.Util.ArgvParser.Extract
(string[] args): changed the regex and changed the
conditions to add an argument as a parameter value.
private void Extract(string[] args)
{
parameters = new StringDictionary();
Regex splitter = new Regex ( @"^([/-]|--){1}(?
<name>\w[\w_+-]*)([:=])?(?<value>.+)?$",
RegexOptions.Compiled); //REGEX
CHANGED (IMPROVED NAME)
char[] trimChars = {'"','\''};
string parameter = null;
Match part;
// Valid parameters forms: {-,/,--}param{ ,
= ,:}((",')value(",'))
// Examples: -param1 value1 --
param2 /param3:"Test-:-work"
// /param4 = happy -param5 '-- = nice = --'
foreach(string arg in args)
{
part = splitter.Match(arg);
if (!part.Success) {
// Found a value (for the
last parameter found (space separator))
if (parameter != null &&
parameters[parameter] == "") { //CONDITION ADDED
parameters[parameter]
= arg.Trim (trimChars);
}
} else {
// Matched a name, optionally
with inline value
parameter = part.Groups
["name"].Value;
parameters.Add (parameter,
part.Groups["value"].Value.Trim (trimChars));
}
}
}
This is just a simple modification. We still parse
wrong in this case:
application -someswitch="" someargument