public Task Create(ShellCommand command) { return new Task(() => { CommandOutput commandOutput; CommandResult output = new CommandResult("", "", ""); try { output = this.commandRunner.RunCommand(command); var resultLog = this.logParser.Parse(output.Result); var outputLog = this.logParser.Parse(output.Output); var errorLog = this.logParser.Parse(output.Error); commandOutput = resultLog; commandOutput.Results.AddRange(outputLog.Results); commandOutput.Results.AddRange(errorLog.Results); } catch (Exception ex) { commandOutput = new CommandOutput("goose", "Failed to run command: " + command.Command, ex.ToString(), CommandOutputItemType.Error); output = new CommandResult(commandOutput.ToString(), "", ""); } this.errorReporter.Report(command, output); this.outputService.Handle(commandOutput); }); }
public void Handle(CommandOutput output) { if (output.Version == 1) { this.HandleMessages(output.Name, output.Time, output.Results); } }
private void ExpectCommandOutput(params string[] messages) { var errors = messages.Select(message => new CommandOutputItem { Type = CommandOutputItemType.Error, Message = message }); var output = new CommandOutput { Results = errors.ToList() }; A.CallTo(() => this.logParser.Parse(A<string>._)).Returns(output); }
public CommandOutput Parse(string buildLog) { if (string.IsNullOrWhiteSpace(buildLog)) { return new CommandOutput(); } CommandOutput result; try { result = this.serializer.Deserialize<CommandOutput>(buildLog); } catch (Exception ex) { result = new CommandOutput("goose", buildLog, "", CommandOutputItemType.Message); } return result; }