disable legacy mode if wanted.

This commit is contained in:
Miroslav Šedivý 2024-09-07 20:51:21 +02:00
parent db297d246d
commit b3b31fba1f
3 changed files with 40 additions and 25 deletions

View file

@ -13,6 +13,7 @@ import (
type Root struct {
Config string
Legacy bool
LogLevel zerolog.Level
LogTime string
@ -33,6 +34,12 @@ func (Root) Init(cmd *cobra.Command) error {
return err
}
// whether legacy configs/api should be enabled (default: true, until v3.1)
cmd.PersistentFlags().BoolP("legacy", "l", true, "enable legacy mode")
if err := viper.BindPFlag("legacy", cmd.PersistentFlags().Lookup("legacy")); err != nil {
return err
}
cmd.PersistentFlags().String("log.level", "info", "set log level (trace, debug, info, warn, error, fatal, panic, disabled)")
if err := viper.BindPFlag("log.level", cmd.PersistentFlags().Lookup("log.level")); err != nil {
return err
@ -72,6 +79,7 @@ func (Root) InitV2(cmd *cobra.Command) error {
func (s *Root) Set() {
s.Config = viper.GetString("config")
s.Legacy = viper.GetBool("legacy")
logLevel := viper.GetString("log.level")
level, err := zerolog.ParseLevel(logLevel)