Beispiel #1
0
        private OptionData AddOption(IOptionInfo info, OptionSet set)
        {
            OptionData s = new OptionData();

            set.Add(info.GetPrototype(), info.Description, v => s.Data.Add(v));
            return(s);
        }
Beispiel #2
0
        private OptionData AddOption(PositionalOptionInfo info, OptionSet set)
        {
            OptionData s = new OptionData();

            set.Add(info.GetPrototype(), info.Description, info.MaxNumValues, v => s.Data.Add(v.ToList()));
            return(s);
        }
Beispiel #3
0
        private static IParsingResult GetParseResult(OptionInfo <string> optionInfo, OptionData optionData)
        {
            ParsingResult <string> result = ParsingResult <string> .SuccessfulResult(optionData.Data.FirstOrDefault());

            if (optionData.Data.Count > 1)
            {
                result = ParsingResult <string> .FailedResult($"Error: {optionInfo.Name} can only be specified once");
            }
            return(optionInfo.Parse(new SuccessfulResultCollection(optionInfo, result)));
        }
Beispiel #4
0
        private OptionSet GetOptionSet(out Dictionary <IOption, OptionData> optionResults)
        {
            optionResults = new Dictionary <IOption, OptionData>();
            OptionSet options = new OptionSet();

            foreach (var option in GetLeafs())
            {
                OptionData result = AddOption(option, options);
                optionResults.Add(option, result);
            }
            return(options);
        }
Beispiel #5
0
 private static IParsingResult GetParseResult(OptionInfo <List <string> > multiOptionInfo, OptionData optionData)
 {
     return(multiOptionInfo.Parse(new SuccessfulResultCollection(multiOptionInfo, ParsingResult <List <string> > .SuccessfulResult(optionData.Data))));
 }
Beispiel #6
0
 private static IParsingResult GetParseResult(OptionInfo <List <string> > multiOptionInfo, OptionData optionData)
 {
     return(multiOptionInfo.Parse(new SuccessfulResultCollection(multiOptionInfo, ParsingResult <List <string> > .SuccessfulResult(optionData.Data.Select(list => list.FirstOrDefault()).ToList()))));
 }