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); }
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"); }
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); }