mirror of
https://github.com/m1k1o/neko.git
synced 2025-05-18 19:47:07 +02:00
disable legacy mode if wanted.
This commit is contained in:
parent
db297d246d
commit
b3b31fba1f
3 changed files with 40 additions and 25 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue