public bool TryParseUnknownCommandArg(string arg, ICommandLineParser parser, out ICommandLineCommand command) { command = null; if (parser.IsSwitch(arg)) { var parameter = arg.Substring(1); switch (parameter.ToLowerInvariant()) { case "?": case "h": case "help": command = new HelpCommand(this.extensions); return(true); } } foreach (var heatExtension in this.extensions) { if (heatExtension.CommandLineTypes.Any(o => o.Option == arg)) { command = new HeatCommand(arg, this.extensions, this.serviceProvider); return(true); } } return(false); }
public bool TryParseArgument(string arg, ICommandLineParser parser) { if (parser.IsSwitch(arg)) { var parameter = arg.Substring(1); switch (parameter.ToLowerInvariant()) { case "?": case "h": case "help": this.ShowHelp = true; return(true); case "intermediatefolder": this.IntermediateFolder = parser.GetNextArgumentAsDirectoryOrError(arg); return(true); case "o": case "out": this.OutputFile = parser.GetNextArgumentAsFilePathOrError(arg); return(true); case "nologo": this.ShowLogo = false; return(true); case "v": case "verbose": this.Messaging.ShowVerboseMessages = true; return(true); case "sw": case "suppresswarning": var warning = parser.GetNextArgumentOrError(arg); if (!String.IsNullOrEmpty(warning)) { var warningNumber = Convert.ToInt32(warning); this.Messaging.SuppressWarningMessage(warningNumber); } return(true); } } else { if (String.IsNullOrEmpty(this.DecompileFilePath)) { this.DecompileFilePath = parser.GetArgumentAsFilePathOrError(arg, "decompile file"); return(true); } else if (String.IsNullOrEmpty(this.OutputFile)) { this.OutputFile = parser.GetArgumentAsFilePathOrError(arg, "output file"); return(true); } } return(false); }
private bool TryParseUnknownCommandArg(string arg, ICommandLineParser parser, out ICommandLineCommand command, IEnumerable <IExtensionCommandLine> extensions) { command = null; if (parser.IsSwitch(arg)) { var parameter = arg.Substring(1); switch (parameter.ToLowerInvariant()) { case "?": case "h": case "help": command = new HelpCommand(); break; case "version": case "-version": command = new VersionCommand(); break; } } else { if (Enum.TryParse(arg, true, out CommandTypes commandType)) { switch (commandType) { case CommandTypes.Build: command = new BuildCommand(this.ServiceProvider); break; case CommandTypes.Compile: command = new CompileCommand(this.ServiceProvider); break; case CommandTypes.Decompile: command = new DecompileCommand(this.ServiceProvider); break; } } else { foreach (var extension in extensions) { if (extension.TryParseCommand(parser, out command)) { break; } command = null; } } } return(command != null); }
public bool TryParseArgument(ICommandLineParser parser, string argument) { if (parser.IsSwitch(argument) && argument.Substring(1).Equals("example", StringComparison.OrdinalIgnoreCase)) { this.exampleValueFromCommandLine = parser.GetNextArgumentOrError(argument); return(true); } return(false); }
public bool TryParseArgument(ICommandLineParser parser, string argument) { if (!parser.IsSwitch(argument)) { if (!this.Subcommand.HasValue) { if (!Enum.TryParse(argument, true, out CacheSubcommand subcommand)) { return(false); } this.Subcommand = subcommand; } else { this.ExtensionReferences.Add(argument); } return(true); } var parameter = argument.Substring(1); switch (parameter.ToLowerInvariant()) { case "?": case "h": case "-help": this.ShowHelp = true; this.ShowLogo = true; this.StopParsing = true; return(true); case "nologo": case "-nologo": this.ShowLogo = false; return(true); case "g": case "-global": this.Global = true; return(true); } return(false); }
public bool TryParseArgument(string arg, ICommandLineParser parser) { if (parser.IsSwitch(arg)) { var parameter = arg.Substring(1); switch (parameter.ToLowerInvariant()) { case "?": case "h": case "help": this.ShowHelp = true; return(true); case "intermediatefolder": this.IntermediateFolder = parser.GetNextArgumentAsDirectoryOrError(arg); return(true); case "o": case "out": this.OutputFile = parser.GetNextArgumentAsFilePathOrError(arg); return(true); case "nologo": this.ShowLogo = false; return(true); case "v": case "verbose": this.Messaging.ShowVerboseMessages = true; return(true); } if (parameter.StartsWith("sw")) { this.ParseSuppressWarning(parameter, "sw".Length, parser); return(true); } else if (parameter.StartsWith("suppresswarning")) { this.ParseSuppressWarning(parameter, "suppresswarning".Length, parser); return(true); } else if (parameter.StartsWith("wx")) { this.ParseWarningAsError(parameter, "wx".Length, parser); return(true); } } else { if (String.IsNullOrEmpty(this.DecompileFilePath)) { this.DecompileFilePath = parser.GetArgumentAsFilePathOrError(arg, "decompile file"); return(true); } else if (String.IsNullOrEmpty(this.OutputFile)) { this.OutputFile = parser.GetArgumentAsFilePathOrError(arg, "output file"); return(true); } } return(false); }
public bool TryParseArgument(string arg, ICommandLineParser parser) { if (parser.IsSwitch(arg)) { var parameter = arg.Substring(1).ToLowerInvariant(); switch (parameter) { case "?": case "h": case "help": this.ShowHelp = true; return(true); case "arch": case "platform": { var value = parser.GetNextArgumentOrError(arg); if (Enum.TryParse(value, true, out Platform platform)) { this.Platform = platform; return(true); } break; } case "bf": case "bindfiles": this.BindFiles = true; return(true); case "bindpath": { var value = parser.GetNextArgumentOrError(arg); if (value != null && this.TryParseBindPath(value, out var bindPath)) { this.BindPaths.Add(bindPath); return(true); } return(false); } case "cc": this.CabCachePath = parser.GetNextArgumentOrError(arg); return(true); case "culture": parser.GetNextArgumentOrError(arg, this.Cultures); return(true); case "contentsfile": this.ContentsFile = parser.GetNextArgumentAsFilePathOrError(arg); return(true); case "outputsfile": this.OutputsFile = parser.GetNextArgumentAsFilePathOrError(arg); return(true); case "builtoutputsfile": this.BuiltOutputsFile = parser.GetNextArgumentAsFilePathOrError(arg); return(true); case "d": case "define": parser.GetNextArgumentOrError(arg, this.Defines); return(true); case "dcl": case "defaultcompressionlevel": { var value = parser.GetNextArgumentOrError(arg); if (Enum.TryParse(value, true, out CompressionLevel compressionLevel)) { this.DefaultCompressionLevel = compressionLevel; return(true); } return(false); } case "i": case "includepath": parser.GetNextArgumentOrError(arg, this.IncludeSearchPaths); return(true); case "intermediatefolder": this.IntermediateFolder = parser.GetNextArgumentAsDirectoryOrError(arg); return(true); case "loc": parser.GetNextArgumentAsFilePathOrError(arg, "localization files", this.LocalizationFilePaths); return(true); case "lib": parser.GetNextArgumentAsFilePathOrError(arg, "library files", this.LibraryFilePaths); return(true); case "o": case "out": this.OutputFile = parser.GetNextArgumentAsFilePathOrError(arg); return(true); case "outputtype": this.OutputType = parser.GetNextArgumentOrError(arg); return(true); case "pdb": this.PdbFile = parser.GetNextArgumentAsFilePathOrError(arg); return(true); case "pdbtype": { var value = parser.GetNextArgumentOrError(arg); if (Enum.TryParse(value, true, out PdbType pdbType)) { this.PdbType = pdbType; return(true); } return(false); } case "nologo": this.ShowLogo = false; return(true); case "v": case "verbose": this.Messaging.ShowVerboseMessages = true; return(true); case "sval": // todo: implement return(true); } if (parameter.StartsWith("sw")) { this.ParseSuppressWarning(parameter, "sw".Length, parser); return(true); } else if (parameter.StartsWith("suppresswarning")) { this.ParseSuppressWarning(parameter, "suppresswarning".Length, parser); return(true); } else if (parameter.StartsWith("wx")) { this.ParseWarningAsError(parameter, "wx".Length, parser); return(true); } return(false); } else { parser.GetArgumentAsFilePathOrError(arg, "source code", this.SourceFilePaths); return(true); } }
public bool TryParseArgument(ICommandLineParser parser, string argument) { if (!parser.IsSwitch(argument)) { this.SearchPatterns.Add(argument); return(true); } var parameter = argument.Substring(1); switch (parameter.ToLowerInvariant()) { case "?": case "h": case "-help": this.ShowHelp = true; this.ShowLogo = true; this.StopParsing = true; return(true); case "n": case "-dry-run": this.DryRun = true; return(true); case "nologo": case "-nologo": this.ShowLogo = false; return(true); case "s": case "r": case "-recurse": case "-recursive": this.Recurse = true; return(true); default: // other parameters if (parameter.StartsWith("set1", StringComparison.Ordinal)) { this.SettingsFile1 = parameter.Substring(4); return(true); } else if (parameter.StartsWith("set2", StringComparison.Ordinal)) { this.SettingsFile2 = parameter.Substring(4); return(true); } else if (parameter.StartsWith("indent:", StringComparison.Ordinal)) { try { this.IndentationAmount = Convert.ToInt32(parameter.Substring(7)); } catch { parser.ReportErrorArgument(parameter); // $"Invalid numeric argument: {parameter}"; } return(true); } return(false); } }
public bool TryParseArgument(string arg, ICommandLineParser parser) { if (parser.IsSwitch(arg)) { var parameter = arg.Substring(1); switch (parameter.ToLowerInvariant()) { case "?": case "h": case "help": this.ShowHelp = true; return(true); case "arch": case "platform": { var value = parser.GetNextArgumentOrError(arg); if (Enum.TryParse(value, true, out Platform platform)) { this.Platform = platform; return(true); } break; } case "bindfiles": this.BindFiles = true; return(true); case "bindpath": { var value = parser.GetNextArgumentOrError(arg); if (this.TryParseBindPath(value, out var bindPath)) { this.BindPaths.Add(bindPath); return(true); } break; } case "cc": this.CabCachePath = parser.GetNextArgumentOrError(arg); return(true); case "culture": parser.GetNextArgumentOrError(arg, this.Cultures); return(true); case "contentsfile": this.ContentsFile = parser.GetNextArgumentAsFilePathOrError(arg); return(true); case "outputsfile": this.OutputsFile = parser.GetNextArgumentAsFilePathOrError(arg); return(true); case "builtoutputsfile": this.BuiltOutputsFile = parser.GetNextArgumentAsFilePathOrError(arg); return(true); case "d": case "define": parser.GetNextArgumentOrError(arg, this.Defines); return(true); case "i": case "includepath": parser.GetNextArgumentOrError(arg, this.IncludeSearchPaths); return(true); case "intermediatefolder": this.IntermediateFolder = parser.GetNextArgumentAsDirectoryOrError(arg); return(true); case "loc": parser.GetNextArgumentAsFilePathOrError(arg, "localization files", this.LocalizationFilePaths); return(true); case "lib": parser.GetNextArgumentAsFilePathOrError(arg, "library files", this.LibraryFilePaths); return(true); case "o": case "out": this.OutputFile = parser.GetNextArgumentAsFilePathOrError(arg); return(true); case "outputtype": this.OutputType = parser.GetNextArgumentOrError(arg); return(true); case "nologo": this.ShowLogo = false; return(true); case "v": case "verbose": this.Messaging.ShowVerboseMessages = true; return(true); case "sval": // todo: implement return(true); case "sw": case "suppresswarning": var warning = parser.GetNextArgumentOrError(arg); if (!String.IsNullOrEmpty(warning)) { var warningNumber = Convert.ToInt32(warning); this.Messaging.SuppressWarningMessage(warningNumber); } return(true); } return(false); } else { parser.GetArgumentAsFilePathOrError(arg, "source code", this.SourceFilePaths); return(true); } }