From 2e80543abfac34044a66e715048b38678abc0a7b Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Tue, 5 Mar 2024 05:37:01 -0500 Subject: [PATCH] refactor: rename output field --- README.md | 4 ++-- internal/stage/model.go | 4 ++-- internal/stage/run.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index be9a5cf..7c93ecc 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ go build -o ./build/joj3 ./cmd/joj3 + cd ./_example/simple + ./../../build/joj3 + cat ./joj3_result.json -[{"Name":"compile","ParserResults":[{"Score":100,"Comment":"compile done, executor status: run time: 265269232 ns, memory: 57790464 bytes"}]},{"Name":"run","ParserResults":[{"Score":100,"Comment":"executor status: run time: 2033735 ns, memory: 13225984 bytes"},{"Score":100,"Comment":"executor status: run time: 3117399 ns, memory: 14548992 bytes"}]}] +[{"Name":"compile","Results":[{"Score":100,"Comment":"compile done, executor status: run time: 265269232 ns, memory: 57790464 bytes"}]},{"Name":"run","Results":[{"Score":100,"Comment":"executor status: run time: 2033735 ns, memory: 13225984 bytes"},{"Score":100,"Comment":"executor status: run time: 3117399 ns, memory: 14548992 bytes"}]}] + rm -f ./joj3_result.json + cd - ``` @@ -27,7 +27,7 @@ Each stage contains a executor and parser. Executor takes a `Cmd` and returns a `ExecutorResult`. -Parser takes a `ExecutorResult` and its config and returns a `ParserResult`. +Parser takes a `ExecutorResult` and its config and returns a `ParserResult` and `bool` to indicate whether we should skip the rest stages. ### `Cmd` diff --git a/internal/stage/model.go b/internal/stage/model.go index 6b8b4c4..61eda07 100644 --- a/internal/stage/model.go +++ b/internal/stage/model.go @@ -164,6 +164,6 @@ type ParserResult struct { } type StageResult struct { - Name string - ParserResults []ParserResult + Name string + Results []ParserResult } diff --git a/internal/stage/run.go b/internal/stage/run.go index 0013df2..78afccb 100644 --- a/internal/stage/run.go +++ b/internal/stage/run.go @@ -25,8 +25,8 @@ func Run(stages []Stage) []StageResult { } slog.Debug("parser run done", "results", parserResults) stageResults = append(stageResults, StageResult{ - Name: stage.Name, - ParserResults: parserResults, + Name: stage.Name, + Results: parserResults, }) if end { break