public static CommandLineOptions Parse(string[] args) { var options = new CommandLineOptions(); options.SolutionFile = string.Empty; var optionType = OptionType.None; foreach (string arg in args) { if (arg.StartsWith("-") || arg.StartsWith("/")) { optionType = options.ParseOptionType(arg.Substring(1)); } else { try { options.ParseOptionArgument(optionType, arg); optionType = OptionType.None; } catch (CommandLineOptionException) { throw; } catch (Exception ex) { throw new CommandLineOptionException("Invalid command line option: {0}: {1}", arg, ex.Message); } } } if (!string.IsNullOrEmpty(options.SolutionFile)) options.SolutionFolderPath = Path.GetDirectoryName(options.SolutionFile); return options; }
public static CommandLineOptions Parse(string[] args) { var options = new CommandLineOptions(); options.SolutionFile = string.Empty; var optionType = OptionType.None; foreach (string arg in args) { if (arg.StartsWith("-") || arg.StartsWith("/")) { optionType = options.ParseOptionType(arg.Substring(1)); } else { try { options.ParseOptionArgument(optionType, arg); optionType = OptionType.None; } catch (CommandLineOptionException) { throw; } catch (Exception ex) { throw new CommandLineOptionException("Invalid command line option: {0}: {1}", arg, ex.Message); } } } if (!string.IsNullOrEmpty(options.SolutionFile)) { options.SolutionFolderPath = Path.GetDirectoryName(options.SolutionFile); } return(options); }