2020-01-19 12:30:09 +13:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
|
|
|
type WebSocket struct {
|
|
|
|
Password string
|
|
|
|
AdminPassword string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (WebSocket) Init(cmd *cobra.Command) error {
|
2020-01-29 14:27:59 +13:00
|
|
|
cmd.PersistentFlags().String("password", "neko", "password for connecting to stream")
|
2020-01-19 12:30:09 +13:00
|
|
|
if err := viper.BindPFlag("password", cmd.PersistentFlags().Lookup("password")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-04-05 13:24:54 +12:00
|
|
|
cmd.PersistentFlags().String("password_admin", "admin", "admin password for connecting to stream")
|
|
|
|
if err := viper.BindPFlag("password_admin", cmd.PersistentFlags().Lookup("password_admin")); err != nil {
|
2020-01-19 12:30:09 +13:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *WebSocket) Set() {
|
|
|
|
s.Password = viper.GetString("password")
|
2020-04-05 13:24:54 +12:00
|
|
|
s.AdminPassword = viper.GetString("password_admin")
|
2020-01-19 12:30:09 +13:00
|
|
|
}
|