aboutsummaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-03-23 23:39:17 +0200
committerTulir Asokan <tulir@maunium.net>2018-03-23 23:39:17 +0200
commit38364646a73a5e666f2db6a34025e2a5a0e3999a (patch)
treec84911c6e8530f55c2fcfc06da587b10bec63547 /config
parent997948ccad0ddd8e7ed2e87cbef1df10e14a3354 (diff)
Refactoring and documentation
Diffstat (limited to 'config')
-rw-r--r--config/config.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/config/config.go b/config/config.go
index 5c1d87c..4ad6793 100644
--- a/config/config.go
+++ b/config/config.go
@@ -26,6 +26,7 @@ import (
"maunium.net/go/gomuks/ui/debug"
)
+// Config contains the main config of gomuks.
type Config struct {
UserID string `yaml:"mxid"`
HS string `yaml:"homeserver"`
@@ -35,6 +36,7 @@ type Config struct {
Session *Session `yaml:"-"`
}
+// NewConfig creates a config that loads data from the given directory.
func NewConfig(dir string) *Config {
return &Config{
Dir: dir,
@@ -42,6 +44,7 @@ func NewConfig(dir string) *Config {
}
}
+// Clear clears the session cache and removes all history.
func (config *Config) Clear() {
if config.Session != nil {
config.Session.Clear()
@@ -49,6 +52,7 @@ func (config *Config) Clear() {
os.RemoveAll(config.HistoryDir)
}
+// Load loads the config from config.yaml in the directory given to the config struct.
func (config *Config) Load() {
os.MkdirAll(config.Dir, 0700)
os.MkdirAll(config.HistoryDir, 0700)
@@ -70,6 +74,7 @@ func (config *Config) Load() {
}
}
+// Save saves this config to config.yaml in the directory given to the config struct.
func (config *Config) Save() {
os.MkdirAll(config.Dir, 0700)
data, err := yaml.Marshal(&config)