public ParseResult Parse(string text) { ParserContext context = new ParserContext(_configuration, text); AbstractState state = new InitialState(context); while (!state.IsTerminal) { state = state.Advance(); } CheckForMissingRequiredParameters(context); return context.Result; }
private void CheckForMissingRequiredParameters(ParserContext context) { if (context.Command != null) { var missing = context.Command.RemainingPositionalParameters.Where(x => x.IsRequired); foreach (var p in missing) { bool ok = false; if (p.IsCollection) { ok = context.Result.CommandListValues.Any(x => x.Name.Equals(p.Name, StringComparison.InvariantCultureIgnoreCase)); } if (!ok) { context.Result.AddError("Required parameter '{0}' was not specified.", p.Name); } } } }