static RpxInterface() { Title = Strings.App_Title + " " + typeof(Program).Assembly.GetName().Version.ToString(); Parser = new ArgumentParser("Rpx", Title + "\n" + Strings.App_AboutText); Parser.AboutTitleText = Title; Parser.AboutText = Strings.App_AboutText; Parser.AboutTextLong = Strings.App_AboutTextLong; Parser.CreditsText = Strings.App_CreditsText; Parser.LegalText = Strings.App_LegalText; Parser.HasApplicationDocument = true; PathString = new StringArgument(Strings.Arg_PathString_Name, Strings.Arg_PathString_ShortHelp, Strings.Arg_PathString_Help); FileList = new StringListArgument(Strings.Arg_FileList_Name, "", Strings.Arg_FileList_Help); Parser.FirstArgument = PathString; Parser.DefaultArgument = FileList; AssemblyInfoPath = new StringArgument(Strings.Arg_AssemblyInfoPath_Name, Strings.Arg_AssemblyInfoPath_ShortHelp, Strings.Arg_AssemblyInfoPath_Help); IconPath = new StringArgument(Strings.Arg_IconPath_Name, Strings.Arg_IconPath_ShortHelp, Strings.Arg_IconPath_Help); OutputPath = new StringArgument(Strings.Arg_OutputPath_Name, Strings.Arg_OutputPath_ShortHelp, Strings.Arg_OutputPath_Help); ConsoleSwitch = new PlusMinusSwitch(Strings.Arg_ConsoleSwitch_ShortHelp, Strings.Arg_ConsoleSwitch_Help, true); PassArgsSwitch = new BoolSwitch(Strings.Arg_PassArgsSwitch_ShortHelp, Strings.Arg_PassArgsSwitch_Help); DecorateSwitch = new BoolSwitch(Strings.Arg_Decorate_ShortHelp, Strings.Arg_Decorate_Help); ProtectZipSwitch = new OptionalStringArgument(Strings.Arg_Hide_Name, Strings.Arg_Hide_ShortHelp, Strings.Arg_Hide_Help); ToolsCsv = new CsvArgument(Strings.Arg_Toolkit_Name, Strings.Arg_Toolkit_ShortHelp, Strings.Arg_Toolkit_Help); Parser.Add(PlusMinusSwitch.KeyPrefix, Strings.Arg_ConsoleSwitch_Symbol, Strings.Arg_ConsoleSwitch_Key, ConsoleSwitch); Parser.Add("/", Strings.Arg_PassArgsSwitch_Symbol, Strings.Arg_PassArgsSwitch_Key, PassArgsSwitch); Parser.Add("/", Strings.Arg_Toolkit_Key, ToolsCsv); Parser.Add("/", Strings.Arg_OutputPath_Symbol, Strings.Arg_OutputPath_Key, OutputPath); Parser.Add("/", Strings.Arg_Decorate_Key, DecorateSwitch); Parser.Add("/", Strings.Arg_IconPath_Symbol, Strings.Arg_IconPath_Key, IconPath); Parser.Add("/", Strings.Arg_AssemblyInfoPath_Symbol, Strings.Arg_AssemblyInfoPath_Key, AssemblyInfoPath); Parser.Add("/", Strings.Arg_Hide_Key, ProtectZipSwitch); BuildSwitch = new BoolSwitch(Strings.Arg_BuildSwitch_ShortHelp, Strings.Arg_BuildSwitch_Help); QuietSwitch = new BoolSwitch(Strings.Arg_QuietSwitch_ShortHelp, Strings.Arg_QuietSwitch_Help); VerboseSwitch = new EnumSwitch(Strings.Arg_Verbose_ShortHelp, Strings.Arg_Verbose_Help, typeof(ConsoleVerbosity)); Parser.Add("/", Strings.Arg_BuildSwitch_Key, BuildSwitch); Parser.Add("/", Strings.Arg_QuietSwitch_Key, QuietSwitch); Parser.Add("/", Strings.Arg_Verbose_Key, VerboseSwitch); WarningsAsErrors = new PlusMinusSwitch(Strings.Arg_WarningsAsErrors_ShortHelp, Strings.Arg_WarningsAsErrors_Help, false); Parser.Add(PlusMinusSwitch.KeyPrefix, Strings.Arg_WarningsAsErrors_Key, WarningsAsErrors); }
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; } }