Beispiel #1
0
        public void ShellCommandOnlyPipesTest()
        {
            ShellParser         shellParser = MakeParser("git reset --hard | echo");
            ShellCommandContext context     = shellParser.shellCommand();
            ShellVisitor        visitor     = new ShellVisitor();

            ParserResult result       = visitor.Visit(context);
            ShellCommand shellCommand = result.ShellCommandValue;

            result.IsShellCommand.Should().BeTrue();
            shellCommand.IsBackground.Should().BeFalse();
            shellCommand.CommandList.Should().HaveCount(2);
        }
Beispiel #2
0
        public void ShellCommandSingleCommandTest()
        {
            ShellParser         shellParser = MakeParser("git reset --hard");
            ShellCommandContext context     = shellParser.shellCommand();
            ShellVisitor        visitor     = new ShellVisitor();

            ParserResult result       = visitor.Visit(context);
            ShellCommand shellCommand = result.ShellCommandValue;

            result.IsShellCommand.Should().BeTrue();
            shellCommand.IsBackground.Should().BeFalse();
            shellCommand.CommandList.Should().HaveCount(1);
            shellCommand.CommandList[0].ToString().Should().Be("git reset --hard");
        }
Beispiel #3
0
        public override ParserResult VisitShellCommand([NotNull] ShellCommandContext context)
        {
            List <SimpleCommand> pipeList = this.VisitPipeList(context.pipeList()).PipeListValue;

            ShellCommand shellCommand = new ShellCommand();

            shellCommand.CommandList = pipeList;

            ParserResult result = new ParserResult(shellCommand);

            result.IsShellCommand = true;

            return(result);
        }