reCoreD-UI/main.go

66 lines
1.3 KiB
Go
Raw Normal View History

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-13 02:30:02 +00:00
_ "reCoreD-UI/docs"
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)
}
2024-04-19 04:47:00 +00:00
// @title reCoreD-UI API
// @version 1.0
// @description APIs for reCoreD-UI
// @BasePath /api/v1
// @securityDefinitions.basic BasicAuth
2024-04-03 09:05:12 +00:00
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-13 02:30:02 +00:00
Name: "mysql-dsn",
Usage: "mysql dsn",
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)
}
}