BREAKING: Rapporter fichiers `pkg/*.go` à la racine BREAKING: Bump version du module à `git.agecem.com/agecem/babillard/v8` et ajuster les références
63 lines
1.3 KiB
Go
63 lines
1.3 KiB
Go
package babillard
|
|
|
|
import (
|
|
"flag"
|
|
"os"
|
|
|
|
"codeberg.org/vlbeaudoin/couleuvre"
|
|
)
|
|
|
|
var app couleuvre.App[Config]
|
|
|
|
func init() {
|
|
app = couleuvre.NewApp[Config]("BABILLARD_", ".", "_")
|
|
|
|
flag.StringVar(&app.Config.ServerContenuDir, ServerContenuDirName, ServerContenuDirDefault, ServerContenuDirDescription)
|
|
flag.IntVar(&app.Config.ServerPort, ServerPortName, ServerPortDefault, ServerPortDescription)
|
|
}
|
|
|
|
const (
|
|
ServerContenuDirName = "servercontenudir"
|
|
ServerContenuDirDefault = "contenu"
|
|
ServerContenuDirDescription = "Répertoire du contenu à exposer"
|
|
|
|
ServerPortName = "serverport"
|
|
ServerPortDefault int = 8080
|
|
ServerPortDescription = "Port réseau à utiliser pour le serveur"
|
|
)
|
|
|
|
const (
|
|
ServerCmdName = "server"
|
|
ServerCmdDesc = "Démarrer le serveur web"
|
|
)
|
|
|
|
func ServerCmdExecuter() error {
|
|
RunServer(app.Config)
|
|
return nil
|
|
}
|
|
|
|
func Execute() error {
|
|
if err := app.Parse(); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := app.NewCommand(ServerCmdName, ServerCmdDesc, ServerCmdExecuter); err != nil {
|
|
return err
|
|
}
|
|
|
|
var commandName string
|
|
if len(os.Args) > 1 {
|
|
commandName = flag.Arg(0)
|
|
}
|
|
|
|
cmd, err := app.ParseCommand(commandName)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := cmd.Execute(); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|