set all settings initially using config.

This commit is contained in:
Miroslav Šedivý 2023-05-14 22:48:13 +02:00
parent cf4e0666fe
commit 0760976b4b
2 changed files with 16 additions and 2 deletions

View File

@ -10,6 +10,8 @@ import (
type Session struct {
File string
PrivateMode bool
LockedControls bool
ImplicitHosting bool
InactiveCursors bool
MercifulReconnect bool
@ -27,6 +29,16 @@ func (Session) Init(cmd *cobra.Command) error {
return err
}
cmd.PersistentFlags().Bool("session.private_mode", false, "whether private mode should be enabled initially")
if err := viper.BindPFlag("session.private_mode", cmd.PersistentFlags().Lookup("session.private_mode")); err != nil {
return err
}
cmd.PersistentFlags().Bool("session.locked_controls", false, "whether controls should be locked for users initially")
if err := viper.BindPFlag("session.locked_controls", cmd.PersistentFlags().Lookup("session.locked_controls")); err != nil {
return err
}
cmd.PersistentFlags().Bool("session.implicit_hosting", true, "allow implicit control switching")
if err := viper.BindPFlag("session.implicit_hosting", cmd.PersistentFlags().Lookup("session.implicit_hosting")); err != nil {
return err
@ -74,6 +86,8 @@ func (Session) Init(cmd *cobra.Command) error {
func (s *Session) Set() {
s.File = viper.GetString("session.file")
s.PrivateMode = viper.GetBool("session.private_mode")
s.LockedControls = viper.GetBool("session.locked_controls")
s.ImplicitHosting = viper.GetBool("session.implicit_hosting")
s.InactiveCursors = viper.GetBool("session.inactive_cursors")
s.MercifulReconnect = viper.GetBool("session.merciful_reconnect")

View File

@ -19,8 +19,8 @@ func New(config *config.Session) *SessionManagerCtx {
logger: log.With().Str("module", "session").Logger(),
config: config,
settings: types.Settings{
PrivateMode: false, // By default disabled.
LockedControls: false, // By default disabled.
PrivateMode: config.PrivateMode,
LockedControls: config.LockedControls,
ImplicitHosting: config.ImplicitHosting,
InactiveCursors: config.InactiveCursors,
MercifulReconnect: config.MercifulReconnect,