JOJ3/internal/parser/file/parser.go
张泊明518370910136 862693bf1f
All checks were successful
submodules sync / sync (push) Successful in 35s
build / build (push) Successful in 1m6s
build / trigger-build-image (push) Successful in 6s
feat(parser/file): show file content
2024-11-29 01:53:30 -05:00

32 lines
602 B
Go

package file
import (
"strings"
"github.com/joint-online-judge/JOJ3/internal/stage"
)
type Conf struct {
Name string
}
type File struct{}
func (*File) Run(results []stage.ExecutorResult, confAny any) (
[]stage.ParserResult, bool, error,
) {
conf, err := stage.DecodeConf[Conf](confAny)
if err != nil {
return nil, true, err
}
var res []stage.ParserResult
for _, result := range results {
content := result.Files[conf.Name]
if !strings.HasSuffix(content, "\n") {
content += "\n"
}
res = append(res, stage.ParserResult{Score: 0, Comment: content})
}
return res, false, nil
}