Fixed bug in helper function where the function wouldn't work with single commands

This commit is contained in:
Lukasz Baldyga committed 2020-10-20 10:05:38 +01:00
1 parent add272ff70
commit 45c93ce079
1 file changed
+9
@@ -94,18 +94,27 @@ namespace Advanced_Software_Engineering {
//split the command from the parameters //split the command from the parameters
string[] parameters = Strip(text).Split(new char[] { " "[0] }, 2); string[] parameters = Strip(text).Split(new char[] { " "[0] }, 2);
//Check there is content
if (parameters.Length > 0) {
//set command var //set command var
string command = Strip(parameters[0]); string command = Strip(parameters[0]);
commandAndParameters["command"] = new string[] { command }; commandAndParameters["command"] = new string[] { command };
}
//If there is nothing split after the first split, why bother doing anything?
else if (parameters.Length > 1) {
//seperate all of the parameters by a comma //seperate all of the parameters by a comma
parameters = parameters[1].Split(","[0]); parameters = parameters[1].Split(","[0]);
//Remove spaces around parameters //Remove spaces around parameters
parameters = StripStringArray(parameters).ToArray(); parameters = StripStringArray(parameters).ToArray();
//We don't want parameters if there aren't any
if (!(parameters.Length == 1 && parameters[0] == "")) {
//set parameter list //set parameter list
commandAndParameters["parameters"] = parameters; commandAndParameters["parameters"] = parameters;
}
}
return commandAndParameters; return commandAndParameters;
} }