MCPcopy Create free account
hub / github.com/LanceLRQ/deer-executor / MakeProblemConfigFile

Function MakeProblemConfigFile

client/generate/problem.go:39–63  ·  view source on GitHub ↗

MakeProblemConfigFile 生成评测配置文件

(c *cli.Context)

Source from the content-addressed store, hash-verified

37
38// MakeProblemConfigFile 生成评测配置文件
39func MakeProblemConfigFile(c *cli.Context) error {
40 config, err := makeProblmConfig()
41 if err != nil {
42 return err
43 }
44 output := c.String("output")
45 if output != "" {
46 s, err := os.Stat(output)
47 if s != nil || os.IsExist(err) {
48 return errors.Errorf("output file exists")
49 }
50 fp, err := os.OpenFile(output, os.O_WRONLY|os.O_CREATE, 0644)
51 if err != nil {
52 return errors.Errorf("open output file error: %s\n", err.Error())
53 }
54 defer fp.Close()
55 _, err = fp.WriteString(utils.ObjectToJSONStringFormatted(config))
56 if err != nil {
57 return err
58 }
59 } else {
60 fmt.Println(utils.ObjectToJSONStringFormatted(config))
61 }
62 return nil
63}
64
65// InitProblemWorkDir 创建一个题目工作目录
66func InitProblemWorkDir(c *cli.Context) error {

Callers

nothing calls this directly

Calls 5

makeProblmConfigFunction · 0.85
ErrorfMethod · 0.80
StringMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected