neko/server/internal/plugins/chat/config.go

24 lines
451 B
Go
Raw Normal View History

2024-06-10 05:05:21 +12:00
package chat
import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
type Config struct {
Enabled bool
}
func (Config) Init(cmd *cobra.Command) error {
cmd.PersistentFlags().Bool("chat.enabled", true, "whether to enable chat plugin")
if err := viper.BindPFlag("chat.enabled", cmd.PersistentFlags().Lookup("chat.enabled")); err != nil {
return err
}
return nil
}
func (s *Config) Set() {
s.Enabled = viper.GetBool("chat.enabled")
}