major v7: Standardiser l'organisation du projet

This commit is contained in:
Victor Lacasse-Beaudoin 2025-01-31 16:37:16 -05:00
parent 7c4e8d8227
commit 6cdc40926b
17 changed files with 72 additions and 66 deletions

34
cmd/babillard/main.go Normal file
View file

@ -0,0 +1,34 @@
/*
Copyright © 2021-2025 AGECEM
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package main
import (
"log"
"git.agecem.com/agecem/babillard/v7/pkg/babillard"
)
func main() {
if err := babillard.Execute(); err != nil {
log.Fatal(err)
}
}

View file

@ -1,65 +0,0 @@
package cmd
import (
"flag"
"os"
"codeberg.org/vlbeaudoin/couleuvre"
"git.agecem.com/agecem/babillard/config"
"git.agecem.com/agecem/babillard/handlers"
)
var app couleuvre.App[config.Config]
func init() {
app = couleuvre.NewApp[config.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 {
handlers.RunServer(app.Config.ServerContenuDir, app.Config.ServerPort)
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
}