mirror of https://github.com/veypi/OneAuth.git
update cli
parent
71924315b4
commit
0e8ef78957
@ -1,36 +0,0 @@
|
||||
//
|
||||
// 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
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
//
|
||||
// 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"
|
||||
"oa/models"
|
||||
|
||||
"github.com/veypi/OneBD/rest/middlewares/crud"
|
||||
)
|
||||
|
||||
var cmdDB = CMD.SubCommand("db", "database operations")
|
||||
|
||||
func init() {
|
||||
cmdDB.SubCommand("migrate", "migrate database").Command = func() error {
|
||||
return crud.AutoMigrate(cfg.DB(), cfg.StaticObjs)
|
||||
}
|
||||
cmdDB.SubCommand("drop", "drop database").Command = func() error {
|
||||
return crud.AutoDrop(cfg.DB(), cfg.StaticObjs)
|
||||
}
|
||||
cmdDB.SubCommand("init", "init db data").Command = models.Init
|
||||
}
|
||||
Loading…
Reference in New Issue