public static int Main(string[] args) { try { Thread.CurrentThread.CurrentCulture = Utility.CultureUS; if (args.Length <= 0) { Console.WriteLine("Usage: SB3UtilityScript \"scriptPath.txt\""); } else { for (int i = 0; i < args.Length; i++) { ScriptMain script = new ScriptMain(); Report.Log += new Action <string>(Logger); script.LoadPlugin((string)script.ScriptEnvironment.Variables[ScriptExecutor.PluginDirectoryName] + "SB3UtilityPlugins.dll"); script.RunScript(args[i]); } } return(0); } catch (Exception ex) { Exception inner = ex; while (inner != null) { Console.WriteLine(inner.Message); inner = inner.InnerException; } return(-1); } }
public object RunScript(string command, bool show = true) { var mem = new MemoryStream(Encoding.UTF8.GetBytes(command)); if ((bool)Gui.Config["CaptureCommands"]) { richTextBoxScript.SuspendLayout(); Color color = (show) ? Color.Empty : SystemColors.GrayText; string cmdShown = command; if (timeStampToolStripMenuItem.Checked) { string timeHeader = "[" + DateTime.Now.Hour.ToString("D2") + ":" + DateTime.Now.Minute.ToString("D2") + "] "; cmdShown = timeHeader + command; } AppendText(cmdShown + (show ? "" : " // GUI only") + Environment.NewLine, color); richTextBoxScript.SelectionStart = richTextBoxScript.Text.Length; richTextBoxScript.ScrollToCaret(); richTextBoxScript.ResumeLayout(); if (autosaveToolStripMenuItem.Checked) { autosaveScriptWriter.WriteLine(command); } } return(ScriptMain.RunScript(mem, "Script")); }
public static int Main(string[] args) { try { Thread.CurrentThread.CurrentCulture = Utility.CultureUS; if (args.Length <= 0) { Console.WriteLine("Usage: SB3UtilityScript \"scriptPath.txt\""); } else { for (int i = 0; i < args.Length; i++) { ScriptMain script = new ScriptMain(); Report.Log += new Action<string>(Logger); script.LoadPlugin((string)script.ScriptEnvironment.Variables[ScriptExecutor.PluginDirectoryName] + "SB3UtilityPlugins.dll"); script.RunScript(args[i]); } } return 0; } catch (Exception ex) { Exception inner = ex; while (inner != null) { Console.WriteLine(inner.Message); inner = inner.InnerException; } return -1; } }
public object RunScript(string command, bool show = true) { var mem = new MemoryStream(Encoding.UTF8.GetBytes(command)); if ((bool)Gui.Config["CaptureCommands"]) { richTextBoxScript.SuspendLayout(); Color color = (show) ? Color.Empty : SystemColors.GrayText; AppendText(command + (show ? "" : " // GUI only") + Environment.NewLine, color); richTextBoxScript.SelectionStart = richTextBoxScript.Text.Length; richTextBoxScript.ScrollToCaret(); richTextBoxScript.ResumeLayout(); if (autosaveToolStripMenuItem.Checked) { autosaveScriptWriter.WriteLine(command); } } return(ScriptMain.RunScript(mem, "Script")); }