69 lines
1.1 KiB
Go
69 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/urfave/cli/v2"
|
|
"log"
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
a := &cli.App{
|
|
Name: "OJ",
|
|
Usage: "woj-server",
|
|
Compiled: getBuildTime(),
|
|
Version: Version,
|
|
EnableBashCompletion: true,
|
|
Authors: []*cli.Author{
|
|
{
|
|
Name: "Paul",
|
|
Email: "i@0x7f.app",
|
|
},
|
|
{
|
|
Name: "cxy004",
|
|
Email: "cxy004@qq.com",
|
|
},
|
|
{
|
|
Name: "wzt",
|
|
Email: "w.zhongtao@qq.com",
|
|
},
|
|
},
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "config",
|
|
Aliases: []string{"c"},
|
|
Usage: "path to the config file",
|
|
Value: "config.yaml",
|
|
EnvVars: []string{"APP_CONFIG"},
|
|
},
|
|
},
|
|
Commands: []*cli.Command{
|
|
{
|
|
Name: "run",
|
|
Aliases: []string{"r"},
|
|
Usage: "start the server",
|
|
Action: run,
|
|
},
|
|
},
|
|
}
|
|
|
|
err := a.Run(os.Args)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
var (
|
|
BuildTime = "2022-09-06-01-00-00"
|
|
Version = "1.0.0+None"
|
|
)
|
|
|
|
func getBuildTime() time.Time {
|
|
build, err := time.Parse("2006-01-02-15-04-05", BuildTime)
|
|
if err != nil {
|
|
log.Printf("failed to parse build time: %v", err)
|
|
build = time.Now()
|
|
}
|
|
return build
|
|
}
|