Exemplo n.º 1
0
        public void WriteIndividualHelpToConsole(ArgumentKey k)
        {
            ConsoleColorState colorState = RugConsole.ColorState;
            IArgumentValue    value2     = this.m_Switches[k];

            RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.SubText, new string('-', RugConsole.BufferWidth) + "[");
            RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.TitleText, k.Prefix + k.Symbol.ToUpper());
            RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.Text, value2.ArgumentString());
            RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.SubText, "] ");
            RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.TitleText, "  " + k.Prefix + k.Symbol.ToUpper());
            if (k.Name.ToUpper().StartsWith(k.Symbol.ToUpper()))
            {
                RugConsole.WriteLine(ConsoleVerbosity.Silent, ConsoleThemeColor.Text, k.Name.Substring(k.Symbol.Length).PadRight(15 - k.Symbol.Length));
            }
            else
            {
                RugConsole.WriteLine(ConsoleVerbosity.Silent, ConsoleThemeColor.Text, (" (" + k.Name + ")").PadRight(15 - k.Symbol.Length));
            }
            RugConsole.WriteLine(ConsoleVerbosity.Silent, ConsoleThemeColor.Text1, "  " + value2.ShortHelp);
            RugConsole.WriteLine(ConsoleVerbosity.Silent, ConsoleThemeColor.TitleText, "");
            if (Helper.IsNotNullOrEmpty(value2.Help))
            {
                RugConsole.WriteInterpreted(ConsoleThemeColor.TitleText, value2.Help, 2, 2);
                RugConsole.WriteLine(ConsoleVerbosity.Silent, "");
            }
            RugConsole.ColorState = colorState;
        }
Exemplo n.º 2
0
        public static void WriteSimpleBanner(string str, char fill, int paddingRight, ConsoleColorExt ForeColour, ConsoleColorExt BackColour)
        {
            ConsoleColorState colorState = RugConsole.ColorState;
            int num   = RugConsole.BufferWidth - paddingRight;
            int count = (num - str.Length) / 2;

            if (ForeColour != ConsoleColorExt.Inhreit)
            {
                RugConsole.ForegroundColor = ForeColour;
            }
            if (BackColour != ConsoleColorExt.Inhreit)
            {
                RugConsole.BackgroundColor = BackColour;
            }
            if (paddingRight > 0)
            {
                RugConsole.Write(ConsoleVerbosity.Silent, new string(fill, count) + str + new string(fill, num - (count + str.Length)));
                RugConsole.ColorState = colorState;
                RugConsole.WriteLine(ConsoleVerbosity.Silent);
            }
            else
            {
                RugConsole.Write(ConsoleVerbosity.Silent, new string(fill, count) + str + new string(fill, num - (count + str.Length)));
                RugConsole.ColorState = colorState;
                RugConsole.Write(ConsoleVerbosity.Silent, new string(' ', RugConsole.BufferWidth));
                if (RugConsole.CanManipulateBuffer)
                {
                    RugConsole.CursorTop--;
                }
            }
        }
Exemplo n.º 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;
     }
 }
Exemplo n.º 4
0
        public void WriteLongArgumentsUsage()
        {
            ConsoleColorState colorState = RugConsole.ColorState;

            this.WriteShortArgumentsUsage();
            if ((this.m_FirstArgument != null) && Helper.IsNotNullOrEmpty(this.m_FirstArgument.Help))
            {
                RugConsole.WriteLine(ConsoleVerbosity.Silent, ConsoleThemeColor.SubText2, "  <" + this.m_FirstArgument.ArgumentString().Trim() + ">");
                RugConsole.WriteWrapped(ConsoleThemeColor.Text1, this.m_FirstArgument.Help, 4, 4);
                RugConsole.WriteLine(ConsoleVerbosity.Silent, "");
            }
            if ((this.m_DefaultArgument != null) && Helper.IsNotNullOrEmpty(this.m_DefaultArgument.Help))
            {
                RugConsole.WriteLine(ConsoleVerbosity.Silent, ConsoleThemeColor.SubText3, "  <" + this.m_DefaultArgument.ArgumentString().Trim() + ">");
                RugConsole.WriteWrapped(ConsoleThemeColor.Text1, this.m_DefaultArgument.Help, 4, 2);
                RugConsole.WriteLine(ConsoleVerbosity.Silent, "");
            }
            foreach (ArgumentKey key in this.m_Switches.Keys)
            {
                IArgumentValue value2 = this.m_Switches[key];
                string         str    = key.Prefix + key.Symbol.ToUpper();
                RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.TitleText, "  " + str);
                if (key.Name.ToUpper().StartsWith(key.Symbol.ToUpper()))
                {
                    RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.Text, key.Name.Substring(key.Symbol.Length).PadRight(0x12 - str.Length));
                }
                else
                {
                    RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.Text, (" (" + key.Name + ")").PadRight(0x12 - str.Length));
                }
                RugConsole.WriteLine(ConsoleVerbosity.Silent, ConsoleThemeColor.Text1, " " + value2.ShortHelp);
            }
            if (this.HasApplicationAbout)
            {
                RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.WarningColor2, "  " + "/?? ".PadRight(0x12));
                RugConsole.WriteLine(ConsoleVerbosity.Silent, ConsoleThemeColor.Text1, " " + Strings.ArgumentParser_AboutScreen_Title);
            }
            if (this.HasApplicationDocument)
            {
                RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.WarningColor2, "  " + "/?D ".PadRight(0x12));
                RugConsole.WriteLine(ConsoleVerbosity.Silent, ConsoleThemeColor.Text1, " " + Strings.ArgumentParser_DocumentGenerator_Title);
            }
            RugConsole.ColorState = colorState;
        }
Exemplo n.º 5
0
        public void WriteShortArgumentsUsage()
        {
            ConsoleColorState colorState = RugConsole.ColorState;

            RugConsole.ForegroundThemeColor = ConsoleThemeColor.TitleText;
            RugConsole.WriteLine(ConsoleVerbosity.Silent, this.m_Description);
            RugConsole.WriteLine(ConsoleVerbosity.Silent);
            int count = this.m_AppName.Length + 1;
            int num2  = count;

            RugConsole.Write(ConsoleVerbosity.Silent, this.m_AppName.ToUpper() + " ");
            if (this.m_FirstArgument != null)
            {
                string str = "<" + this.m_FirstArgument.ArgumentString().Trim() + "> ";
                num2 += str.Length + str.Length;
                if (num2 > RugConsole.BufferWidth)
                {
                    num2 = count;
                    RugConsole.WriteLine();
                    RugConsole.Write(new string(' ', count));
                }
                RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.SubText2, str);
            }
            if (this.m_DefaultArgument != null)
            {
                string str2 = "<" + this.m_DefaultArgument.ArgumentString().Trim() + "> ";
                num2 += str2.Length;
                if (num2 > RugConsole.BufferWidth)
                {
                    num2 = count + str2.Length;
                    RugConsole.WriteLine();
                    RugConsole.Write(new string(' ', count));
                }
                RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.SubText3, str2);
            }
            foreach (ArgumentKey key in this.m_Switches.Keys)
            {
                IArgumentValue value2 = this.m_Switches[key];
                int            num3   = ((key.Prefix.Length + key.Symbol.Length) + value2.ArgumentString().Length) + 3;
                num2 += num3;
                if (num2 > RugConsole.BufferWidth)
                {
                    num2 = count + num3;
                    RugConsole.WriteLine();
                    RugConsole.Write(new string(' ', count));
                }
                RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.SubText, "[");
                RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.TitleText, key.Prefix + key.Symbol.ToUpper());
                RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.Text, value2.ArgumentString());
                RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.SubText, "] ");
            }
            if (this.HasApplicationAbout)
            {
                int num4 = 4;
                num2 += num4;
                if (num2 > RugConsole.BufferWidth)
                {
                    num2 = count + num4;
                    RugConsole.WriteLine();
                    RugConsole.Write(new string(' ', count));
                }
                RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.WarningColor2, "/?? ");
            }
            if (this.HasApplicationDocument)
            {
                int num5 = 11;
                num2 += num5;
                if (num2 > RugConsole.BufferWidth)
                {
                    num2 = count + num5;
                    RugConsole.WriteLine();
                    RugConsole.Write(new string(' ', count));
                }
                RugConsole.Write(ConsoleVerbosity.Silent, ConsoleThemeColor.WarningColor2, "/?D <path> ");
            }
            RugConsole.ColorState = colorState;
            RugConsole.WriteLine(ConsoleVerbosity.Silent);
            RugConsole.WriteLine(ConsoleVerbosity.Silent);
        }
Exemplo n.º 6
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;
            }
        }