Updates the commandline parser to not be broken.

It should now correctly parse a commandline such as `["", "-flag", "-flag", "arg" ... "etc" ]`
This commit is contained in:
Chris 2017-12-09 15:19:34 +10:30
parent eda2870bb1
commit c4129cf645

View file

@ -165,10 +165,16 @@ namespace TShockAPI.CLI
{ {
_source = source; _source = source;
for (int i = 0; i < (source.Length - 1 == 0 ? 1 : source.Length - 1); i++) for (int i = 0; i < (source.Length - 1 == 0 ? 1 : source.Length); i++)
{ {
string flag = source[i].ToLowerInvariant(); string flag = source[i].ToLowerInvariant();
string argument = null; string argument = null;
if (string.IsNullOrWhiteSpace(flag))
{
continue;
}
if (i + 1 < source.Length) if (i + 1 < source.Length)
{ {
argument = source[i + 1]; argument = source[i + 1];