public string Execute(int index) { if (index < 0 || index >= Entries.Count) { throw new Exception("Tried to execute command from history at nonexistant index."); } return(_Executor.ExecuteCommand(_Parser.Parse(Entries[index]), index)); }
//public string ExecuteLua(string src) { // if (src == ".quit") { // LuaMode = false; // return "[left lua mode]"; // } // var lua = ModUntitled.ModLoader.LuaState; // lua.EnterArea(); // var top1 = lua.StackTop; // lua.BeginProtCall(); // lua.LoadString(src); // lua.ExecProtCall(0, cleanup: true); // var top2 = lua.StackTop; // object ret = null; // if (top2 - top1 >= 1) { // ret = lua.ToCLR(); // lua.Pop(); // } // lua.LeaveArea(); // if (ret == null) return "[no result]"; // else return ret.ToString(); //} //public void ExecuteLuaAndPrintResult(string src) { // if (PrintUsedCommand) PrintLine("> " + src, color: UnityUtil.NewColorRGB(87, 87, 87)); // try { // PrintLine(ExecuteLua(src)); // } catch (Exception e) { // PrintError("Exception while running Lua:"); // PrintError(e.Message); // PrintError("More detailed info in the log."); // _Logger.Error($"Exception while running Lua snippet: '{src}':"); // var stlines = e.ToString().Split('\n'); // for (int i = 0; i < stlines.Length; i++) { // _Logger.ErrorIndent(stlines[i]); // } // } //} public string ExecuteCommand(string cmd) { return(_Executor.ExecuteCommand(_Parser.Parse(cmd))); }