private int RunCommandLine() { Debug.Assert(_engine != null); _commandLine = CreateCommandLine(); ConsoleOptions consoleOptions = _languageOptionsParser.CommonConsoleOptions; if (consoleOptions.PrintVersionAndExit) { Console.WriteLine("{0} {1} on .NET {2}", Engine.Setup.DisplayName, Engine.LanguageVersion, typeof(String).Assembly.GetName().Version); return(0); } if (consoleOptions.PrintUsageAndExit) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("Usage: {0}.exe ", ExeName); PrintLanguageHelp(sb); Console.Write(sb.ToString()); return(0); } if (_console == null) { _console = CreateConsole(Engine, _commandLine, consoleOptions); } int exitCode = 0; try { if (consoleOptions.HandleExceptions) { try { exitCode = _commandLine.Run(Engine, _console, consoleOptions); } catch (Exception e) { if (CommandLine.IsFatalException(e)) { // Some exceptions are too dangerous to try to catch throw; } UnhandledException(Engine, e); exitCode = 1; } } else { exitCode = _commandLine.Run(Engine, _console, consoleOptions); } } finally { try { Snippets.SaveAndVerifyAssemblies(); } catch (Exception) { exitCode = 1; } } return(exitCode); }
private int RunCommandLine() { Debug.Assert(_engine != null); _commandLine = CreateCommandLine(); if (_console == null) { _console = CreateConsole(Engine, _commandLine, _consoleOptions); } int?exitCodeOverride = null; try { if (_consoleOptions.HandleExceptions) { try { _commandLine.Run(Engine, _console, _consoleOptions); } catch (Exception e) { if (CommandLine.IsFatalException(e)) { // Some exceptions are too dangerous to try to catch throw; } UnhandledException(Engine, e); } } else { _commandLine.Run(Engine, _console, _consoleOptions); } } finally { #if FEATURE_REFEMIT try { Snippets.SaveAndVerifyAssemblies(); } catch (Exception) { exitCodeOverride = 1; } #endif } if (exitCodeOverride == null) { return(_commandLine.ExitCode); } else { return(exitCodeOverride.Value); } }
private int RunCommandLine() { Debug.Assert(_engine != null); _commandLine = CreateCommandLine(); if (_console == null) { _console = CreateConsole(Engine, _commandLine, _consoleOptions); } int? exitCodeOverride = null; try { if (_consoleOptions.HandleExceptions) { try { _commandLine.Run(Engine, _console, _consoleOptions); } catch (Exception e) { if (CommandLine.IsFatalException(e)) { // Some exceptions are too dangerous to try to catch throw; } UnhandledException(Engine, e); } } else { _commandLine.Run(Engine, _console, _consoleOptions); } } finally { try { Snippets.SaveAndVerifyAssemblies(); } catch (Exception) { exitCodeOverride = 1; } } if (exitCodeOverride == null) { return _commandLine.ExitCode; } else { return exitCodeOverride.Value; } }
public override void Initialize() { DLRIntegrationAddIn addIn = CurrentSession.AddInManager.GetAddIn<DLRIntegrationAddIn>(); _virtualConsole = new VirtualConsole(CurrentSession, Console); addIn.ScriptRuntime.IO.SetOutput(MemoryStream.Null, _virtualConsole.Output); addIn.ScriptRuntime.IO.SetErrorOutput(MemoryStream.Null, _virtualConsole.Output); HostingHelpers.GetDomainManager(addIn.ScriptRuntime).SharedIO.SetOutput(new VirtualStream(Console), _virtualConsole.Output); HostingHelpers.GetDomainManager(addIn.ScriptRuntime).SharedIO.SetErrorOutput(new VirtualStream(Console), _virtualConsole.Output); _commandLine = new RubyCommandLine();//(CurrentServer, CurrentSession); ConsoleOptions consoleOptions = new RubyConsoleOptions(); addIn.ScriptRuntime.Globals.SetVariable("Session", CurrentSession); addIn.ScriptRuntime.Globals.SetVariable("CurrentSession", CurrentSession); addIn.ScriptRuntime.Globals.SetVariable("Server", CurrentServer); addIn.ScriptRuntime.Globals.SetVariable("CurrentServer", CurrentServer); _consoleThread = new Thread(t => { _commandLine.Run(addIn.ScriptRuntime.GetEngine("rb"), _virtualConsole, consoleOptions); }); _consoleThread.Start(); base.Initialize(); }
private int RunCommandLine() { Debug.Assert(_engine != null); _commandLine = CreateCommandLine(); ConsoleOptions consoleOptions = _languageOptionsParser.CommonConsoleOptions; if (consoleOptions.PrintVersionAndExit) { Console.WriteLine("{0} {1} on .NET {2}", Engine.Setup.DisplayName, Engine.LanguageVersion, typeof(String).Assembly.GetName().Version); return 0; } if (consoleOptions.PrintUsageAndExit) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("Usage: {0}.exe ", ExeName); PrintLanguageHelp(sb); Console.Write(sb.ToString()); return 0; } if (_console == null) { _console = CreateConsole(Engine, _commandLine, consoleOptions); } int exitCode = 0; try { if (consoleOptions.HandleExceptions) { try { exitCode = _commandLine.Run(Engine, _console, consoleOptions); } catch (Exception e) { if (CommandLine.IsFatalException(e)) { // Some exceptions are too dangerous to try to catch throw; } UnhandledException(Engine, e); exitCode = 1; } } else { exitCode = _commandLine.Run(Engine, _console, consoleOptions); } } finally { try { Snippets.SaveAndVerifyAssemblies(); } catch (Exception) { exitCode = 1; } } return exitCode; }