Ejemplo n.º 1
0
        public string GetIndividualHelpString(ArgumentKey k)
        {
            StringBuilder  builder = new StringBuilder();
            IArgumentValue value2  = this.m_Switches[k];

            builder.Append("[" + k.Prefix + k.Symbol.ToUpper() + value2.ArgumentString() + "] ");
            string str = k.Symbol.ToUpper();

            if (k.Name.ToUpper().StartsWith(k.Symbol.ToUpper()))
            {
                str = str + k.Name.Substring(k.Symbol.Length);
            }
            else
            {
                str = str + " (" + k.Name + ")";
            }
            builder.AppendLine("  " + k.Prefix + str);
            builder.AppendLine("  " + value2.ShortHelp);
            builder.AppendLine();
            if (Helper.IsNotNullOrEmpty(value2.Help))
            {
                builder.AppendLine(ConsoleFormatter.StripFormat(value2.Help));
                builder.AppendLine();
            }
            return(builder.ToString());
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 public IArgumentValue GetForKey(string keyIn, out ArgumentKey outKey)
 {
     foreach (ArgumentKey key in this.m_Switches.Keys)
     {
         if (key.Equals(keyIn))
         {
             outKey = key;
             return(this.m_Switches[key]);
         }
     }
     outKey = null;
     return(null);
 }
Ejemplo n.º 5
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;
            }
        }
Ejemplo n.º 6
0
 public IArgumentValue GetForKey(string keyIn, out ArgumentKey outKey)
 {
     foreach (ArgumentKey key in this.m_Switches.Keys)
     {
         if (key.Equals(keyIn))
         {
             outKey = key;
             return this.m_Switches[key];
         }
     }
     outKey = null;
     return null;
 }
Ejemplo n.º 7
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;
 }
Ejemplo n.º 8
0
 public string GetIndividualHelpString(ArgumentKey k)
 {
     StringBuilder builder = new StringBuilder();
     IArgumentValue value2 = this.m_Switches[k];
     builder.Append("[" + k.Prefix + k.Symbol.ToUpper() + value2.ArgumentString() + "] ");
     string str = k.Symbol.ToUpper();
     if (k.Name.ToUpper().StartsWith(k.Symbol.ToUpper()))
     {
         str = str + k.Name.Substring(k.Symbol.Length);
     }
     else
     {
         str = str + " (" + k.Name + ")";
     }
     builder.AppendLine("  " + k.Prefix + str);
     builder.AppendLine("  " + value2.ShortHelp);
     builder.AppendLine();
     if (Helper.IsNotNullOrEmpty(value2.Help))
     {
         builder.AppendLine(ConsoleFormatter.StripFormat(value2.Help));
         builder.AppendLine();
     }
     return builder.ToString();
 }