feat: déplacer déclaration de flags à serpents
#10
3 changed files with 55 additions and 2569 deletions
|
@ -5,11 +5,13 @@ import (
|
|||
"log"
|
||||
"net/http"
|
||||
|
||||
"codeberg.org/vlbeaudoin/serpents"
|
||||
"git.agecem.com/agecem/babillard/handlers"
|
||||
"git.agecem.com/agecem/babillard/public"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
|
@ -27,15 +29,17 @@ var serverCmd = &cobra.Command{
|
|||
|
||||
func init() {
|
||||
rootCmd.AddCommand(serverCmd)
|
||||
declareFlags()
|
||||
declareFlags(serverCmd.Flags())
|
||||
}
|
||||
|
||||
func declareFlags() {
|
||||
serverCmd.Flags().IntP("port", "p", 8080, "Port réseau à utiliser (config: \"server.port\")")
|
||||
viper.BindPFlag("server.port", serverCmd.Flags().Lookup("port"))
|
||||
func declareFlags(flagSet *pflag.FlagSet) {
|
||||
if err := serpents.IntP(flagSet, "server.port", "port", "p", 8080, "Port réseau à utiliser pour le serveur"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
serverCmd.Flags().String("contenu_dir", "contenu", "Répertoire du contenu à exposer (config: \"server.contenu_dir\")")
|
||||
viper.BindPFlag("server.contenu_dir", serverCmd.Flags().Lookup("contenu_dir"))
|
||||
if err := serpents.String(flagSet, "server.contenu_dir", "contenu_dir", "contenu", "Répertoire du contenu à exposer"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func runServer(port int) {
|
||||
|
|
45
go.mod
45
go.mod
|
@ -1,23 +1,46 @@
|
|||
module git.agecem.com/agecem/babillard
|
||||
|
||||
go 1.16
|
||||
go 1.21.1
|
||||
|
||||
toolchain go1.21.3
|
||||
|
||||
require (
|
||||
github.com/bketelsen/crypt v0.0.4 // indirect
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
codeberg.org/vlbeaudoin/serpents v1.1.0
|
||||
github.com/labstack/echo/v4 v4.11.3
|
||||
github.com/spf13/cobra v1.8.0
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/spf13/viper v1.17.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/labstack/gommon v0.4.1 // indirect
|
||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
|
||||
github.com/rogpeppe/go-internal v1.10.0 // indirect
|
||||
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
||||
github.com/smartystreets/goconvey v1.6.4 // indirect
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/spf13/afero v1.11.0 // indirect
|
||||
github.com/spf13/cast v1.6.0 // indirect
|
||||
github.com/spf13/cobra v1.8.0
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/viper v1.17.0
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/crypto v0.16.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect
|
||||
golang.org/x/net v0.19.0 // indirect
|
||||
golang.org/x/sys v0.15.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/time v0.5.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue