private static StatePair <IEnumerable <Token> > Tokenize(IEnumerable <string> arguments, IEnumerable <OptionSpecification> optionSpecs, ParserSettings settings) { return(settings.EnableDashDash ? Tokenizer.PreprocessDashDash( arguments, args => Tokenizer.Tokenize(args, name => NameLookup.Contains(name, optionSpecs, settings.NameComparer))) : Tokenizer.Tokenize(arguments, name => NameLookup.Contains(name, optionSpecs, settings.NameComparer))); }
private static Result <IEnumerable <Token>, Error> Tokenize( IEnumerable <string> arguments, IEnumerable <OptionSpecification> optionSpecs, ParserSettings settings) { var tokens = settings.EnableDashDash ? Tokenizer.PreprocessDashDash( arguments, args => Tokenizer.Tokenize(args, name => NameLookup.Contains(name, optionSpecs, settings.NameComparer))) : Tokenizer.Tokenize(arguments, name => NameLookup.Contains(name, optionSpecs, settings.NameComparer)); var explodedTokens = Tokenizer.ExplodeOptionList(tokens, name => NameLookup.HavingSeparator(name, optionSpecs, settings.NameComparer)); return(explodedTokens); }
private static Result <IEnumerable <Token>, Error> Tokenize( IEnumerable <string> arguments, IEnumerable <OptionSpecification> optionSpecs, ParserSettings settings) { var normalize = settings.IgnoreUnknownArguments ? toks => Tokenizer.Normalize(toks, name => NameLookup.Contains(name, optionSpecs, settings.NameComparer) != NameLookupResult.NoOptionFound) : new Func <IEnumerable <Token>, IEnumerable <Token> >(toks => toks); var tokens = settings.EnableDashDash ? Tokenizer.PreprocessDashDash( arguments, args => Tokenizer.Tokenize(args, name => NameLookup.Contains(name, optionSpecs, settings.NameComparer), normalize)) : Tokenizer.Tokenize(arguments, name => NameLookup.Contains(name, optionSpecs, settings.NameComparer), normalize); var explodedTokens = Tokenizer.ExplodeOptionList(tokens, name => NameLookup.HavingSeparator(name, optionSpecs, settings.NameComparer)); return(explodedTokens); }
public void Double_dash_force_subsequent_arguments_as_values() { // Fixture setup var expectedResult = new Simple_Options_With_Values { StringValue = "str1", LongValue = 10L, StringSequence = new[] { "-a", "--bee", "-c" }, IntValue = 20 }; var arguments = new[] { "--stringvalue", "str1", "--", "10", "-a", "--bee", "-c", "20" }; // Exercize system var result = InstanceBuilder.Build( Maybe.Just <Func <Simple_Options_With_Values> >(() => new Simple_Options_With_Values()), (a, optionSpecs) => Tokenizer.PreprocessDashDash(a, args => Tokenizer.Tokenize(args, name => NameLookup.Contains(name, optionSpecs, StringComparer.Ordinal))), arguments, StringComparer.Ordinal, false, CultureInfo.InvariantCulture, true, true, Enumerable.Empty <ErrorType>()); // Verify outcome expectedResult.Should().BeEquivalentTo(((Parsed <Simple_Options_With_Values>)result).Value); // Teardown }
public void Double_dash_force_subsequent_arguments_as_values() { // Fixture setup var expectedResult = new FakeOptionsWithValues { StringValue = "str1", LongValue = 10L, StringSequence = new[] { "-a", "--bee", "-c" }, IntValue = 20 }; var arguments = new[] { "--stringvalue", "str1", "--", "10", "-a", "--bee", "-c", "20" }; // Exercize system var result = InstanceBuilder.Build( () => new FakeOptionsWithValues(), (a, optionSpecs) => Tokenizer.PreprocessDashDash(a, args => Tokenizer.Tokenize(args, name => NameLookup.Contains(name, optionSpecs, StringComparer.Ordinal))), arguments, StringComparer.Ordinal, CultureInfo.InvariantCulture); // Verify outcome expectedResult.ShouldHave().AllProperties().EqualTo(result.Value); // Teardown }