Exemplo n.º 1
0
        public void SimpleCommandNoArgsTest()
        {
            ShellParser          shellParser = MakeParser("git");
            SimpleCommandContext context     = shellParser.simpleCommand();
            ShellVisitor         visitor     = new ShellVisitor();

            ParserResult  result        = visitor.Visit(context);
            SimpleCommand actualCommand = result.SimpleCommandValue;

            result.IsSimpleCommand.Should().BeTrue();
            actualCommand.Command.Should().Be("git");
            actualCommand.Arguments.Should().BeEmpty();
        }
Exemplo n.º 2
0
        public void SimpleCommandWithArgsTest()
        {
            ShellParser          shellParser = MakeParser("git reset --hard");
            SimpleCommandContext context     = shellParser.simpleCommand();
            ShellVisitor         visitor     = new ShellVisitor();

            ParserResult  result        = visitor.Visit(context);
            SimpleCommand actualCommand = result.SimpleCommandValue;

            result.IsSimpleCommand.Should().BeTrue();
            actualCommand.Command.Should().Be("git");
            actualCommand.Arguments.Should().BeEquivalentTo(new List <string> {
                "reset", "--hard"
            }, opt => opt.WithStrictOrdering());
        }
Exemplo n.º 3
0
        public override ParserResult VisitSimpleCommand([NotNull] SimpleCommandContext context)
        {
            string command = this.VisitCmd(context.cmd()).CmdValue;
            IEnumerable <string> arguments = Enumerable.Empty <string>();

            if (context.args() != null)
            {
                arguments = this.VisitArgs(context.args()).ArgListValue;
            }

            SimpleCommand simpleCommand = new SimpleCommand(command, arguments);
            ParserResult  result        = new ParserResult(simpleCommand);

            result.IsSimpleCommand = true;

            return(result);
        }