mirror of
https://github.com/m1k1o/neko.git
synced 2026-11-03 08:21:50 -06:00
disable legacy mode if wanted.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user