private CommandParser GetSimplifiedParser() { var verbParser = VerbGrammar.GetParser(); var argParser = SimplifiedArgumentGrammar.GetParser(); var scriptParser = ScriptFormatGrammar.CreateParser(verbParser); return(new CommandParser(verbParser, argParser, scriptParser)); }
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"); }
private static IParser <char, IParsedArgument> GetParser() => SimplifiedArgumentGrammar.GetParser();
/// <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())); }