2024-04-03 09:05:12 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2024-04-10 05:24:01 +00:00
|
|
|
"reCoreD-UI/cmd/config"
|
|
|
|
"reCoreD-UI/cmd/server"
|
2024-04-03 09:05:12 +00:00
|
|
|
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
"github.com/urfave/cli/v2/altsrc"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
logrus.SetReportCaller(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
flags := []cli.Flag{
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "config",
|
|
|
|
Usage: "config yaml file",
|
|
|
|
Aliases: []string{"c"},
|
|
|
|
EnvVars: []string{"RECORED_CONFIG_FILE"},
|
|
|
|
},
|
2024-04-10 05:24:01 +00:00
|
|
|
altsrc.NewStringFlag(&cli.StringFlag{
|
2024-04-03 09:05:12 +00:00
|
|
|
Name: "mysql-dsn",
|
|
|
|
Usage: "mysql dsn",
|
2024-04-09 13:16:19 +00:00
|
|
|
EnvVars: []string{"RECORED_MYSQL_DSN"},
|
2024-04-10 05:24:01 +00:00
|
|
|
}),
|
|
|
|
altsrc.NewBoolFlag(&cli.BoolFlag{
|
2024-04-03 09:05:12 +00:00
|
|
|
Name: "debug",
|
|
|
|
Usage: "enable debug mode",
|
|
|
|
Value: false,
|
|
|
|
Action: func(ctx *cli.Context, b bool) error {
|
|
|
|
if b {
|
|
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
2024-04-10 05:24:01 +00:00
|
|
|
}),
|
2024-04-03 09:05:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
app := &cli.App{
|
|
|
|
Name: "reCoreD-UI",
|
|
|
|
Usage: "Web UI for CoreDNS",
|
|
|
|
Before: altsrc.InitInputSourceWithContext(
|
|
|
|
flags, altsrc.NewYamlSourceFromFlagFunc("config"),
|
|
|
|
),
|
|
|
|
Flags: flags,
|
2024-04-10 05:24:01 +00:00
|
|
|
Commands: []*cli.Command{
|
|
|
|
server.Command,
|
|
|
|
config.Command,
|
|
|
|
},
|
2024-04-03 09:05:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
|
|
logrus.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|