Example #1
0
 public PositionalOption(Func <T1, T2, T3, IParsingResult <TOut> > parse, bool isMultiValue, bool required, string overallDescription, ValueOption <T1> option1, ValueOption <T2> option2, ValueOption <T3> option3, params string[] names)
 {
     _required = required;
     _parse    = parse;
     _option1  = option1;
     _option2  = option2;
     _option3  = option3;
     Info      = new PositionalOptionInfo(required, isMultiValue, overallDescription, new IOptionInfo[] { option1.Info, option2.Info, option3.Info }, names);
 }
Example #2
0
        public bool Equals(ValueOption <T> p)
        {
            // If parameter is null return false:
            if (p == null)
            {
                return(false);
            }

            return(Info.Equals(p.Info) && Equals(_defaultValue, p._defaultValue));
        }
Example #3
0
 public MultiValueOption(ValueOption <T> valueOption)
 {
     _valueOption = valueOption;
     if (valueOption.Info is RequiredValueOptionInfo)
     {
         Info = new RequiredMultiOptionInfo(valueOption.Info);
     }
     else
     {
         Info = new MultipleValueOptionInfo(false, valueOption.Info);
     }
 }
Example #4
0
 public MultiValueOption(ValueOption <T> valueOption)
 {
     _valueOption = valueOption;
     if (valueOption.Info is RequiredValueOptionInfo)
     {
         Info = new RequiredMultiOptionInfo(valueOption.Info);
     }
     else
     {
         Info = new ValueOptionInfo <List <string> >(false, valueOption.Info);
     }
 }
Example #5
0
        private IParsingResult <T> GetOptionResult <T>(int valueIndex, List <string> values, ValueOption <T> option1)
        {
            string value = valueIndex < values.Count ? values[valueIndex] : null;

            if (option1.Info is RequiredValueOptionInfo && value == null)
            {
                return(ParsingResult <T> .FailedResult($"{option1.Info.Name} is a required positional argument for option {Info.Name}"));
            }
            return(option1.Parse(value));
        }
Example #6
0
 public SinglePositionalOption(Func <T1, T2, T3, IParsingResult <TOut> > parse, bool required, string overallDescription, ValueOption <T1> option1, ValueOption <T2> option2, ValueOption <T3> option3, params string[] names)
 {
     PositionalOption = new PositionalOption <T1, T2, T3, TOut>(parse, false, required, overallDescription, option1, option2, option3, names);
 }