/// <exception cref="Exception">On error.</exception> protected override void ParseArgument(string arg) { ContractUtils.RequiresNotNull(arg, "arg"); string mainFileFromPath = null; if (arg.StartsWith("-e", StringComparison.Ordinal)) { string command; if (arg == "-e") { command = PopNextArg(); } else { command = arg.Substring(2); } LanguageSetup.Options["MainFile"] = "-e"; if (CommonConsoleOptions.Command == null) { CommonConsoleOptions.Command = String.Empty; } else { CommonConsoleOptions.Command += "\n"; } CommonConsoleOptions.Command += command; return; } if (arg.StartsWith("-S", StringComparison.Ordinal)) { mainFileFromPath = arg == "-S" ? PopNextArg() : arg.Substring(2); } if (arg.StartsWith("-I", StringComparison.Ordinal)) { string includePaths; if (arg == "-I") { includePaths = PopNextArg(); } else { includePaths = arg.Substring(2); } _loadPaths.AddRange(GetPaths(includePaths)); return; } if (arg.StartsWith("-K", StringComparison.Ordinal)) { _defaultEncoding = arg.Length >= 3 ? RubyEncoding.GetEncodingByNameInitial(arg[2]) : null; return; } if (arg.StartsWith("-r", StringComparison.Ordinal)) { _requiredPaths.Add((arg == "-r") ? PopNextArg() : arg.Substring(2)); return; } if (arg.StartsWith("-C", StringComparison.Ordinal)) { ConsoleOptions.ChangeDirectory = arg.Substring(2); return; } if (arg.StartsWith("-0", StringComparison.Ordinal) || arg.StartsWith("-C", StringComparison.Ordinal) || arg.StartsWith("-F", StringComparison.Ordinal) || arg.StartsWith("-i", StringComparison.Ordinal) || arg.StartsWith("-T", StringComparison.Ordinal) || arg.StartsWith("-x", StringComparison.Ordinal)) { throw new InvalidOptionException(String.Format("Option `{0}' not supported", arg)); } int colon = arg.IndexOf(':'); string optionName, optionValue; if (colon >= 0) { optionName = arg.Substring(0, colon); optionValue = arg.Substring(colon + 1); } else { optionName = arg; optionValue = null; } switch (optionName) { #region Ruby options case "-a": case "-c": case "--copyright": case "-l": case "-n": case "-p": case "-s": throw new InvalidOptionException(String.Format("Option `{0}' not supported", optionName)); case "-d": LanguageSetup.Options["DebugVariable"] = true; // $DEBUG = true break; case "--version": ConsoleOptions.PrintVersion = true; ConsoleOptions.Exit = true; break; case "-v": ConsoleOptions.DisplayVersion = true; goto case "-W2"; case "-W0": LanguageSetup.Options["Verbosity"] = 0; // $VERBOSE = nil break; case "-W1": LanguageSetup.Options["Verbosity"] = 1; // $VERBOSE = false break; case "-w": case "-W2": LanguageSetup.Options["Verbosity"] = 2; // $VERBOSE = true break; #endregion #if DEBUG && !SILVERLIGHT case "-DT*": SetTraceFilter(String.Empty, false); break; case "-DT": SetTraceFilter(PopNextArg(), false); break; case "-ET*": SetTraceFilter(String.Empty, true); break; case "-ET": SetTraceFilter(PopNextArg(), true); break; case "-ER": RubyOptions.ShowRules = true; break; case "-save": LanguageSetup.Options["SavePath"] = optionValue ?? AppDomain.CurrentDomain.BaseDirectory; break; case "-load": LanguageSetup.Options["LoadFromDisk"] = ScriptingRuntimeHelpers.True; break; case "-useThreadAbortForSyncRaise": RubyOptions.UseThreadAbortForSyncRaise = true; break; case "-compileRegexps": RubyOptions.CompileRegexps = true; break; #endif case "-trace": LanguageSetup.Options["EnableTracing"] = ScriptingRuntimeHelpers.True; break; case "-profile": LanguageSetup.Options["Profile"] = ScriptingRuntimeHelpers.True; break; case "-1.8.6": case "-1.8.7": case "-1.9": case "-2.0": throw new InvalidOptionException(String.Format("Option `{0}' is no longer supported. The compatible Ruby version is 1.9.", optionName)); case "--disable-gems": _disableRubyGems = true; break; case "-X": switch (optionValue) { case "AutoIndent": case "TabCompletion": case "ColorfulConsole": throw new InvalidOptionException(String.Format("Option `{0}' not supported", optionName)); } goto default; default: base.ParseArgument(arg); if (ConsoleOptions.FileName != null) { if (mainFileFromPath != null) { ConsoleOptions.FileName = FindMainFileFromPath(mainFileFromPath); } if (ConsoleOptions.Command == null) { SetupOptionsForMainFile(); } else { SetupOptionsForCommand(); } } break; } }