Пример #1
0
        private CommandParser GetSimplifiedParser()
        {
            var verbParser   = VerbGrammar.GetParser();
            var argParser    = SimplifiedArgumentGrammar.GetParser();
            var scriptParser = ScriptFormatGrammar.CreateParser(verbParser);

            return(new CommandParser(verbParser, argParser, scriptParser));
        }
Пример #2
0
        public void UseParser_Test()
        {
            var output     = new TestOutput();
            var verbParser = VerbGrammar.GetParser();
            var engine     = new EngineBuilder()
                             .SetupHandlers(h => h.UseHandlerTypes(typeof(TestHandler)))
                             .SetupOutput(o => o.DoNotUseConsole().Add(output))
                             .SetupArguments(a => a.UseParser(new CommandParser(verbParser, SimplifiedArgumentGrammar.GetParser(), ScriptFormatGrammar.CreateParser(verbParser))))
                             .Build();

            engine.RunHeadless("test a b=x -c");
            output.Lines.Count.Should().Be(3);
            output.Lines[0].Should().Be("a");
            output.Lines[1].Should().Be("x");
            output.Lines[2].Should().Be("True");
        }
Пример #3
0
 private static IParser <char, IParsedArgument> GetParser()
 => SimplifiedArgumentGrammar.GetParser();
Пример #4
0
 /// <summary>
 /// Use the StoneFruit simplified argument syntax
 /// </summary>
 /// <param name="setup"></param>
 /// <returns></returns>
 public static IParserSetup UseSimplifiedArgumentParser(this IParserSetup setup)
 {
     Assert.ArgumentNotNull(setup, nameof(setup));
     return(setup.UseArgumentParser(SimplifiedArgumentGrammar.GetParser()));
 }