feat(parser/file): show file content
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

This commit is contained in:
张泊明518370910136 2024-11-29 01:53:30 -05:00
parent 96ed65f05d
commit 862693bf1f
GPG Key ID: D47306D7062CDA9D
3 changed files with 41 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import (
_ "github.com/joint-online-judge/JOJ3/internal/parser/cpplint" _ "github.com/joint-online-judge/JOJ3/internal/parser/cpplint"
_ "github.com/joint-online-judge/JOJ3/internal/parser/diff" _ "github.com/joint-online-judge/JOJ3/internal/parser/diff"
_ "github.com/joint-online-judge/JOJ3/internal/parser/dummy" _ "github.com/joint-online-judge/JOJ3/internal/parser/dummy"
_ "github.com/joint-online-judge/JOJ3/internal/parser/file"
_ "github.com/joint-online-judge/JOJ3/internal/parser/healthcheck" _ "github.com/joint-online-judge/JOJ3/internal/parser/healthcheck"
_ "github.com/joint-online-judge/JOJ3/internal/parser/keyword" _ "github.com/joint-online-judge/JOJ3/internal/parser/keyword"
_ "github.com/joint-online-judge/JOJ3/internal/parser/resultdetail" _ "github.com/joint-online-judge/JOJ3/internal/parser/resultdetail"

View File

@ -0,0 +1,9 @@
package file
import "github.com/joint-online-judge/JOJ3/internal/stage"
var name = "file"
func init() {
stage.RegisterParser(name, &File{})
}

View File

@ -0,0 +1,31 @@
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
}