private bool DoParseArguments(string[] args, object options) { bool hadError = false; var optionMap = OptionInfo.CreateMap(options, _settings); var target = new TargetWrapper(options); IArgumentEnumerator arguments = new StringArrayEnumerator(args); while (arguments.MoveNext()) { string argument = arguments.Current; if (argument != null && argument.Length > 0) { ArgumentParser parser = ArgumentParser.Create(argument); //, target); if (parser != null) { ParserState result = parser.Parse(arguments, optionMap, options); if ((result & ParserState.Failure) == ParserState.Failure) { hadError = true; break; } if ((result & ParserState.MoveOnNextElement) == ParserState.MoveOnNextElement) arguments.MoveNext(); } else if (target.IsValueListDefined) { if (!target.AddValueItemIfAllowed(argument)) { hadError = true; break; } } } } hadError |= !optionMap.EnforceRules(); return !hadError; }
private bool DoParseArguments(string[] args, object options) { bool hadError = false; var optionMap = OptionInfo.CreateMap(options, _settings); var target = new TargetWrapper(options); IArgumentEnumerator arguments = new StringArrayEnumerator(args); while (arguments.MoveNext()) { var argument = arguments.Current; if (!string.IsNullOrEmpty(argument)) { var parser = ArgumentParser.Create(argument); if (parser != null) { var result = parser.Parse(arguments, optionMap, options); if ((result & ParserState.Failure) == ParserState.Failure) { SetPostParsingStateIfNeeded(options, parser.PostParsingState); hadError = true; continue; //break; } if ((result & ParserState.MoveOnNextElement) == ParserState.MoveOnNextElement) arguments.MoveNext(); } else if (target.IsValueListDefined) { if (!target.AddValueItemIfAllowed(argument)) { hadError = true; } } } } hadError |= !optionMap.EnforceRules(); return !hadError; }