private static 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 = GetCommandTerms(commandStr); if (commandTerms.Length == 0) { throw(new CommandException("Empty Command passed '{0}'", commandStr)); } CommandDef commandDef = CommandRegistry.GetCommand(commandTerms[0]); if (!commandDef.IsValid()) { throw(new CommandException("Unrecognised Command '{0}'", commandTerms[0])); } commandStr = FixCommandFormat(commandTerms, commandDef); return(commandDef.Command.ExecuteCommand(commandTerms)); }