feat(parser/resultdetail): show files
All checks were successful
build / build (push) Successful in 2m15s
build / trigger-build-image (push) Successful in 11s

This commit is contained in:
张泊明518370910136 2024-10-10 18:47:01 -04:00
parent 8bf63594f0
commit 7648dde9da
GPG Key ID: D47306D7062CDA9D

View File

@ -13,6 +13,7 @@ type Conf struct {
ShowTime bool `default:"true"` ShowTime bool `default:"true"`
ShowMemory bool `default:"true"` ShowMemory bool `default:"true"`
ShowRunTime bool `default:"false"` ShowRunTime bool `default:"false"`
ShowFiles []string
} }
type ResultDetail struct{} type ResultDetail struct{}
@ -44,6 +45,15 @@ func (*ResultDetail) Run(results []stage.ExecutorResult, confAny any) (
if conf.ShowRunTime { if conf.ShowRunTime {
comment += fmt.Sprintf("RunTime: %d\n", result.RunTime) comment += fmt.Sprintf("RunTime: %d\n", result.RunTime)
} }
for _, file := range conf.ShowFiles {
content, ok := result.Files[file]
comment += fmt.Sprintf("File: `%s`.\n", file)
if ok {
comment += fmt.Sprintf("```%s```\n", content)
} else {
comment += "Not found.\n"
}
}
res = append(res, stage.ParserResult{ res = append(res, stage.ParserResult{
Score: conf.Score, Score: conf.Score,
Comment: comment, Comment: comment,