change!: move config to cmd.app.Config

bump: couleuvre -> `v0.10.0`

Move `couleuvre.NewApp` to `cmd.init`

Make flags target `&cmd.app.Config`

Fix `ServerCmdExecuter`'s `RunServer` parameters

Fix call to `app.Parse` in `cmd.Execute`

BREAKING: Remove `cmd.Cfg()`
BREAKING: Remove `cmd.cfg config.Config`
This commit is contained in:
Victor Lacasse-Beaudoin 2023-12-04 21:26:50 -05:00
parent a3c2c8d1f0
commit 72ff53f846
3 changed files with 10 additions and 12 deletions

View file

@ -9,13 +9,13 @@ import (
"git.agecem.com/agecem/babillard/handlers"
)
var cfg config.Config
func Cfg() config.Config { return cfg }
var app couleuvre.App[config.Config]
func init() {
flag.StringVar(&cfg.ServerContenuDir, ServerContenuDirName, ServerContenuDirDefault, ServerContenuDirDescription)
flag.IntVar(&cfg.ServerPort, ServerPortName, ServerPortDefault, ServerPortDescription)
app = couleuvre.NewApp[config.Config]("BABILLARD_", ".", "_")
flag.StringVar(&app.Config.ServerContenuDir, ServerContenuDirName, ServerContenuDirDefault, ServerContenuDirDescription)
flag.IntVar(&app.Config.ServerPort, ServerPortName, ServerPortDefault, ServerPortDescription)
}
const (
@ -34,14 +34,12 @@ const (
)
func ServerCmdExecuter() error {
handlers.RunServer(Cfg())
handlers.RunServer(app.Config.ServerContenuDir, app.Config.ServerPort)
return nil
}
func Execute() error {
app := couleuvre.NewApp("BABILLARD_", ".", "_")
if err := app.Parse(&cfg); err != nil {
if err := app.Parse(); err != nil {
return err
}