You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/cli/args.go

37 lines
1.1 KiB
Go

//
// Copyright (C) 2024 veypi <i@veypi.com>
// 2025-03-04 16:08:06
// Distributed under terms of the MIT license.
//
package main
import (
"oa/cfg"
"github.com/veypi/utils/flags"
"github.com/veypi/utils/logv"
)
var CMD = flags.New("app", "the backend server of app")
var CfgDump = CMD.SubCommand("cfg", "generate cfg file")
var configFile = CMD.String("f", "./dev.yaml", "the config file")
func init() {
CMD.StringVar(&cfg.Config.Host, "host", "0.0.0.0", "host")
CMD.IntVar(&cfg.Config.Port, "p", 4000, "port")
CMD.StringVar(&cfg.Config.LoggerLevel, "l", "info", "log level")
CMD.StringVar(&cfg.Config.DSN, "dsn", "root:123456@tcp(127.0.0.1:3306)/test?charset=utf8&parseTime=True&loc=Local", "data source name")
CMD.StringVar(&cfg.Config.DB, "db", "mysql", "data source type: mysql/postgre/sqlite")
CMD.Before = func() error {
flags.LoadCfg(*configFile, cfg.Config)
CMD.Parse()
logv.SetLevel(logv.AssertFuncErr(logv.ParseLevel(cfg.Config.LoggerLevel)))
return nil
}
CfgDump.Command = func() error {
flags.DumpCfg(*configFile, cfg.Config)
return nil
}
}