neko/internal/config/session.go

24 lines
491 B
Go
Raw Normal View History

package config
import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
2020-11-02 06:39:12 +13:00
type Session struct {
2020-12-02 23:24:20 +13:00
ImplicitHosting bool
}
2020-11-02 06:39:12 +13:00
func (Session) Init(cmd *cobra.Command) error {
2020-12-02 23:24:20 +13:00
cmd.PersistentFlags().Bool("implicit_hosting", true, "allow implicit control switching")
if err := viper.BindPFlag("implicit_hosting", cmd.PersistentFlags().Lookup("implicit_hosting")); err != nil {
return err
}
return nil
}
2020-11-02 06:39:12 +13:00
func (s *Session) Set() {
2020-12-02 23:24:20 +13:00
s.ImplicitHosting = viper.GetBool("implicit_hosting")
}