BREAKING: Déplacer config à cmd.app.Config et bump couleuvre #14

Merged
vlbeaudoin merged 3 commits from refactor/app-config into main 2023-12-04 21:32:39 -05:00
3 changed files with 10 additions and 12 deletions
Showing only changes of commit 72ff53f846 - Show all commits

View file

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

2
go.mod
View file

@ -5,7 +5,7 @@ go 1.21.3
toolchain go1.21.4 toolchain go1.21.4
require ( require (
codeberg.org/vlbeaudoin/couleuvre v0.8.0 codeberg.org/vlbeaudoin/couleuvre v0.10.0
github.com/labstack/echo/v4 v4.11.3 github.com/labstack/echo/v4 v4.11.3
) )

4
go.sum
View file

@ -1,5 +1,5 @@
codeberg.org/vlbeaudoin/couleuvre v0.8.0 h1:61lJ8zICGWiBX2Ao0+p1L+fU78KKibgJ5M6kCFHXjN0= codeberg.org/vlbeaudoin/couleuvre v0.10.0 h1:Uk6795M7ziZPu1Fv8KgGNEbRjc1u4NPdPU4Tip0IpHU=
codeberg.org/vlbeaudoin/couleuvre v0.8.0/go.mod h1:+M8nPA/3LknsY72RP0ZHCZycQ1SPxxRoXpnyHeSNE7U= codeberg.org/vlbeaudoin/couleuvre v0.10.0/go.mod h1:+M8nPA/3LknsY72RP0ZHCZycQ1SPxxRoXpnyHeSNE7U=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=