示例#1
0
        static void StoreOptions(ArgumentModel model, ParseResult parseResult)
        {
            foreach (var tokenGroup in parseResult.TokenGroups)
            {
                var modelOption = model.FindOptionByToken(tokenGroup.Option);

                object value = modelOption.Definition.Strategy.GetValue(modelOption, tokenGroup);
                modelOption.Property.SetValue(model.CliArguments, value);
            }
            model.CliArguments.Operands = parseResult.Operands.Select(t => t.Value).ToArray();
        }
示例#2
0
        static void ValidateTokensForDuplicateOptions(ArgumentModel model, List <TokenGroup> tokenGroups)
        {
            var duplicates = tokenGroups
                             .Select(a => model.FindOptionByToken(a.Option).Definition)
                             .Duplicates(new BaseOptionAttributeEqualityComparer());

            if (duplicates.Any())
            {
                throw new DuplicateOptionException(
                          $"Duplicate options were provided for "
                          + $"{string.Join("/", duplicates.Select(o => o.LongName))}");
            }
        }