static private string FixCommandFormat(string[] commandTerms, CommandDef commandDef) { string ret = commandDef.Name; int numTerms = Mathf.Min(commandTerms.Length, commandDef.Command.GetNumExpectedTerms()); for (int i = 1; i < numTerms; i++) { ret += " " + commandTerms[i]; } return(ret); }
public static object ExecuteCommand(ref string commandStr) { string[] commandTerms = Utils.GetCommandTerms(commandStr); if (commandTerms.Length == 0) { throw(new CommandConsoleException("Empty Command passed '{0}'", commandStr)); } CommandDef commandDef = CommandRegistry.GetCommand(commandTerms[0]); if (commandDef == null) { throw(new CommandConsoleException("Unrecognised Command '{0}'", commandTerms[0])); } commandStr = FixCommandFormat(commandTerms, commandDef); return(commandDef.Command.ExecuteCommand(commandTerms)); }