public override bool Parse(ArgumentParser parser, string key, string[] values, ref int index)
 {
     if ((index + 1) < values.Length)
     {
         string str  = values[index + 1];
         string str2 = str;
         if (str.StartsWith("-") || str.StartsWith("+"))
         {
             str2 = ConsoleChars.GetMathsChar(ConsoleMathsChars.PlusMinus) + key.Substring(1);
         }
         ArgumentKey    outKey = null;
         IArgumentValue forKey = null;
         if (parser.ContainsKey(str))
         {
             forKey = parser.GetForKey(str, out outKey);
         }
         else if (!str2.Equals(str) && parser.ContainsKey(str2))
         {
             forKey = parser.GetForKey(str2, out outKey);
         }
         if ((outKey == null) || (forKey == null))
         {
             this.SetValue(values[index + 1]);
             index++;
         }
     }
     return(false);
 }
Beispiel #2
0
        public static void WriteStackTrace(string trace)
        {
            ConsoleColor foregroundColor = Console.ForegroundColor;

            Console.WriteLine();
            Console.ForegroundColor = (ConsoleColor)Theme[ConsoleThemeColor.ErrorColor2];
            Console.WriteLine(new string(ConsoleChars.GetShade(ConsoleShade.Dim), BufferWidth));
            Console.ForegroundColor = (ConsoleColor)Theme[ConsoleThemeColor.TitleText];
            Console.WriteLine("  " + trace.Replace("\n", "\n  "));
            Console.WriteLine();
            Console.ForegroundColor = (ConsoleColor)Theme[ConsoleThemeColor.ErrorColor2];
            Console.WriteLine(new string(ConsoleChars.GetShade(ConsoleShade.Dim), BufferWidth));
            Console.WriteLine();
            Console.ForegroundColor = foregroundColor;
        }
Beispiel #3
0
 public static void WriteLogo(int x, int y, int pixWidth, int pixHeight, ConsoleShade fillShade, ConsoleShade endShade, ConsoleShade shadowShade, string[] lines)
 {
     if (RugConsole.CanManipulateBuffer)
     {
         ConsoleColorState colorState = RugConsole.ColorState;
         int    cursorLeft            = RugConsole.CursorLeft;
         int    cursorTop             = RugConsole.CursorTop;
         string str  = new string(ConsoleChars.GetShade(fillShade), pixWidth);
         string str2 = "";
         if (pixWidth > 1)
         {
             str2 = new string(ConsoleChars.GetShade(fillShade), pixWidth - 1) + ConsoleChars.GetShade(endShade);
         }
         else
         {
             str2 = new string(ConsoleChars.GetShade(endShade), 1);
         }
         string str3 = new string(ConsoleChars.GetShade(ConsoleShade.Clear), pixWidth);
         string str4 = new string(ConsoleChars.GetShade(shadowShade), pixWidth);
         string str5 = "";
         if (pixWidth > 1)
         {
             str5 = new string(ConsoleChars.GetShade(shadowShade), 1) + new string(ConsoleChars.GetShade(ConsoleShade.Clear), pixWidth - 1);
         }
         else
         {
             str5 = new string(ConsoleChars.GetShade(shadowShade), 1);
         }
         int num3 = y;
         RugConsole.CursorLeft           = x;
         RugConsole.CursorTop            = num3++;
         RugConsole.ForegroundThemeColor = ConsoleThemeColor.TitleText;
         for (int i = 0; i < lines.Length; i++)
         {
             for (int j = 0; j < pixHeight; j++)
             {
                 RugConsole.Write(string.Format(lines[i], new object[] { str, str2, str3, str4, str5 }));
                 RugConsole.CursorLeft = x;
                 RugConsole.CursorTop  = num3++;
             }
         }
         RugConsole.ColorState = colorState;
         RugConsole.CursorTop  = cursorTop;
         RugConsole.CursorLeft = cursorLeft;
     }
 }
Beispiel #4
0
        public void Parse(string[] args)
        {
            ConsoleColorState colorState = RugConsole.ColorState;

            try
            {
                if (args.Length > 0)
                {
                    int num = 0;
                    StringListArgument firstArgument = null;
                    if (args[0] == "/?")
                    {
                        if (args.Length == 1)
                        {
                            this.WriteLongArgumentsUsage();
                        }
                        else
                        {
                            this.WriteShortArgumentsUsage();
                        }
                        this.m_HelpMode = true;
                        num++;
                    }
                    else if (args[0] == "/??")
                    {
                        this.WriteApplicationAboutToConsole(true);
                        this.m_HelpMode = true;
                        num++;
                    }
                    else
                    {
                        if (args[0].Equals("/?D", StringComparison.CurrentCultureIgnoreCase))
                        {
                            string str;
                            if (args.Length > 1)
                            {
                                str = args[1];
                            }
                            else
                            {
                                str = Path.Combine(Environment.CurrentDirectory, this.m_AppName + " Documentation.txt");
                            }
                            this.WriteApplicationDocumentationToPath(str);
                            this.m_HelpMode = true;
                            return;
                        }
                        if (this.m_FirstArgument != null)
                        {
                            this.m_FirstArgument.SetValue(args[0]);
                            this.m_FirstArgument.Defined = true;
                            if (this.m_FirstArgument is StringListArgument)
                            {
                                firstArgument = this.m_FirstArgument as StringListArgument;
                            }
                            num++;
                        }
                    }
                    int index  = num;
                    int length = args.Length;
                    while (index < length)
                    {
                        string str2 = args[index];
                        string str3 = str2;
                        if (str2.StartsWith("-") || str2.StartsWith("+"))
                        {
                            str3 = ConsoleChars.GetMathsChar(ConsoleMathsChars.PlusMinus) + str2.Substring(1);
                        }
                        ArgumentKey    outKey = null;
                        IArgumentValue forKey = null;
                        if (this.ContainsKey(str2))
                        {
                            forKey = this.GetForKey(str2, out outKey);
                        }
                        else if (!str3.Equals(str2) && this.ContainsKey(str3))
                        {
                            forKey = this.GetForKey(str3, out outKey);
                        }
                        if ((outKey != null) && (forKey != null))
                        {
                            if (this.m_HelpMode)
                            {
                                this.WriteIndividualHelpToConsole(outKey);
                            }
                            else
                            {
                                forKey.Defined = true;
                                if (forKey.Parse(this, str2, args, ref index))
                                {
                                    firstArgument = forKey as StringListArgument;
                                }
                                else
                                {
                                    firstArgument = null;
                                }
                            }
                        }
                        else if ((firstArgument != null) && !this.m_HelpMode)
                        {
                            firstArgument.SetValue(str2);
                        }
                        else
                        {
                            if ((this.m_DefaultArgument == null) || this.m_HelpMode)
                            {
                                throw new Exception(string.Format(Strings.ArgumentParser_InvalidSwitch, str2));
                            }
                            this.m_DefaultArgument.SetValue(str2);
                        }
                        index++;
                    }
                }
            }
            finally
            {
                RugConsole.ColorState = colorState;
            }
        }