/IronPython_2_0/Src/IronPythonConsole/Console.cs
C# | 76 lines | 46 code | 13 blank | 17 comment | 4 complexity | 5776adeb54477c2608af8d2c65bc2b4c MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0
- /* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation.
- *
- * This source code is subject to terms and conditions of the Microsoft Public License. A
- * copy of the license can be found in the License.html file at the root of this distribution. If
- * you cannot locate the Microsoft Public License, please send an email to
- * ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
- * by the terms of the Microsoft Public License.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
- using System; using Microsoft;
- using System.Text;
- using IronPython.Hosting;
- using IronPython.Runtime;
- using Microsoft.Scripting.Hosting;
- using Microsoft.Scripting.Hosting.Shell;
- using Microsoft.Scripting.Utils;
- using System.Diagnostics;
- using System.Reflection.Emit;
-
- internal sealed class PythonConsoleHost : ConsoleHost {
-
- protected override Type Provider {
- get { return typeof(PythonContext); }
- }
-
- protected override CommandLine/*!*/ CreateCommandLine() {
- return new PythonCommandLine();
- }
-
- protected override OptionsParser/*!*/ CreateOptionsParser() {
- return new PythonOptionsParser();
- }
-
- protected override LanguageSetup/*!*/ CreateLanguageSetup() {
- return Python.CreateLanguageSetup(null);
- }
-
- protected override string/*!*/ GetHelp() {
- StringBuilder sb = new StringBuilder();
-
- sb.AppendLine(PythonCommandLine.GetLogoDisplay());
- PrintLanguageHelp(sb);
- sb.AppendLine();
-
- return sb.ToString();
- }
-
- protected override void ParseHostOptions(string/*!*/[]/*!*/ args) {
- // Python doesn't want any of the DLR base options.
- foreach (string s in args) {
- Options.IgnoredArgs.Add(s);
- }
- }
-
- [STAThread]
- public static int Main(string[] args) {
- // Work around issue w/ pydoc - piping to more doesn't work so
- // instead indicate that we're a dumb terminal
- if (Environment.GetEnvironmentVariable("TERM") == null) {
- Environment.SetEnvironmentVariable("TERM", "dumb");
- }
-
- if (typeof(DynamicMethod).GetConstructor(new Type[] { typeof(string), typeof(Type), typeof(Type[]), typeof(bool) }) == null) {
- Console.WriteLine("IronPython requires .NET 2.0 SP1 or later to run.");
- Environment.Exit(1);
- }
-
- return new PythonConsoleHost().Run(args);
- }
- }