feat(parser/file): show file content
This commit is contained in:
parent
96ed65f05d
commit
862693bf1f
|
@ -6,6 +6,7 @@ import (
|
|||
_ "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/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/keyword"
|
||||
_ "github.com/joint-online-judge/JOJ3/internal/parser/resultdetail"
|
||||
|
|
9
internal/parser/file/meta.go
Normal file
9
internal/parser/file/meta.go
Normal 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{})
|
||||
}
|
31
internal/parser/file/parser.go
Normal file
31
internal/parser/file/parser.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user