-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.go
105 lines (102 loc) · 2.52 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package main
import (
"fmt"
"github.com/LanceLRQ/deer-executor/v2/agent"
agentConfig "github.com/LanceLRQ/deer-executor/v2/agent/config"
"github.com/LanceLRQ/deer-executor/v2/client"
"github.com/LanceLRQ/deer-executor/v2/client/generate"
"github.com/LanceLRQ/deer-executor/v2/client/run"
"github.com/gookit/config/v2"
"github.com/gookit/config/v2/yamlv3"
"github.com/urfave/cli/v2"
"log"
"os"
)
var (
buildGitHash string
buildTime string
buildGoVersion string
buildVersion string
)
func main() {
main := &cli.App{
Name: "Deer Executor",
HelpName: "deer-executor",
Usage: "An executor for online judge.",
Writer: os.Stderr,
Action: func(c *cli.Context) error {
fmt.Println("Deer Executor\n--------------------")
fmt.Printf("version: %s (built %s)\n", buildVersion, buildTime)
fmt.Printf("commit: %s \n", buildGitHash)
fmt.Printf("compiler: %s\n", buildGoVersion)
return nil
},
Commands: cli.Commands{
{
Name: "run",
Usage: "run code judging",
Aliases: []string{"r"},
ArgsUsage: "<config_file|problem_package> <code_file>",
Action: run.UserRunJudge,
Flags: client.RunFlags,
},
{
Name: "example",
Aliases: []string{"e"},
Usage: "generate all kinds of configuration files",
Subcommands: client.AppGeneratorSubCommands,
},
{
Name: "new",
Aliases: []string{"n"},
ArgsUsage: "<output_dir>",
Usage: "create a new problem with example",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Value: "a+b",
Usage: "template file name (found in ./lib/example/)",
},
},
Action: generate.InitProblemWorkDir,
},
{
Name: "package",
Usage: "package manager",
Subcommands: client.AppPackageSubCommands,
},
{
Name: "problem",
Aliases: []string{"p"},
Usage: "problem manager",
Subcommands: client.AppProblemSubCommands,
},
{
Name: "agent",
Hidden: true,
Usage: "judge service agent service",
Before: func(c *cli.Context) error {
config.AddDriver(yamlv3.Driver)
err := config.LoadFiles(c.String("config"))
if err != nil {
return err
}
// 载入服务端配置
return agentConfig.LoadGlobalConf()
},
Action: agent.LaunchJudgeService,
Flags: agent.JudgeServiceCommandFlags,
},
{
Name: "test",
Hidden: true,
Usage: "",
Action: client.Test,
},
},
}
err := main.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}