private ParameterMapping( ParameterModel parameterModel, IReadOnlyList <string> suppliedValues) { SuppliedValues = suppliedValues; ConvertToType = parameterModel.ParameterType; }
public Option <(ParameterMapping, CommandLineArgumentList remainingArguments)> NamedPass( ParameterModel parameterModel, CommandLineArgumentList args) { var argumentsMatched = new List <CommandLineArgument>(); var suppliedValues = new List <string>(); using (var enumerator = args.GetEnumerator()) { while (enumerator.MoveNext()) { switch (enumerator.Current) { case CommandLineArgument.NameValuePair nvPair when parameterModel.MatchesName(nvPair.Name): argumentsMatched.Add(nvPair); if (parameterModel.AllowMultipleValues) { suppliedValues.Add(nvPair.Value); continue; } return( new ParameterMapping.NamedValue(parameterModel, ListOf(nvPair.Value)), args.Without(argumentsMatched)); case CommandLineArgument.BareNameOrFlag nameOrFlag when parameterModel.MatchesName(nameOrFlag.Name) && parameterModel.IsFlag: argumentsMatched.Add(nameOrFlag); return( new ParameterMapping.Flag(parameterModel), args.Without(argumentsMatched)); case CommandLineArgument.BareNameOrFlag bnf when parameterModel.MatchesName(bnf.Name): if (enumerator.MoveNext()) { if (enumerator.Current is CommandLineArgument.Free free) { argumentsMatched.Add(bnf); argumentsMatched.Add(free); if (parameterModel.AllowMultipleValues) { suppliedValues.Add(free.Value); continue; } return( new ParameterMapping.NamedValue( parameterModel, ListOf(free.Value)), args.Without(argumentsMatched)); } } break; default: break; } } } if (parameterModel.AllowMultipleValues && suppliedValues.Any()) { return( new ParameterMapping.NamedValue(parameterModel, suppliedValues), args.Without(argumentsMatched)); } return(default);
public NoValue(ParameterModel parameterModel) : base(parameterModel, ListOf <string>()) { }
public Flag(ParameterModel parameterModel) : base(parameterModel, ListOf($"{true}")) { }
public PositionalValue( ParameterModel parameterModel, IReadOnlyList <string> suppliedValues) : base(parameterModel, suppliedValues) { }