aboutsummaryrefslogtreecommitdiffstats
path: root/config/config.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-11-15 22:50:49 +0100
committerRobin Jarry <robin@jarry.cc>2022-11-16 16:12:09 +0100
commitf8e88632c49a4bd70efb503944f642e7daed37d8 (patch)
tree0424095855417c868b96d44a773fe3e24f3dfbba /config/config.go
parent3710e459825b78a5adfa7af04128713010e4c9e4 (diff)
downloadaerc-f8e88632c49a4bd70efb503944f642e7daed37d8.tar.gz
config: move [statusline] in separate file
The config.go file is getting too big. Move the aerc.conf [statusline] section parsing logic into a dedicated statusline.go file. No functional change. Please ignore the casual "realignment" of fields in the default config initialization. Thanks gofmt. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'config/config.go')
-rw-r--r--config/config.go41
1 files changed, 12 insertions, 29 deletions
diff --git a/config/config.go b/config/config.go
index 0c2bf5f3..ef824279 100644
--- a/config/config.go
+++ b/config/config.go
@@ -16,12 +16,6 @@ import (
"git.sr.ht/~rjarry/aerc/logging"
)
-type StatuslineConfig struct {
- RenderFormat string `ini:"render-format"`
- Separator string
- DisplayMode string `ini:"display-mode"`
-}
-
type TriggersConfig struct {
NewEmail string `ini:"new-email"`
ExecuteCommand func(command []string) error
@@ -133,11 +127,6 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
}
}
}
- if statusline, err := file.GetSection("statusline"); err == nil {
- if err := statusline.MapTo(&config.Statusline); err != nil {
- return err
- }
- }
if triggers, err := file.GetSection("triggers"); err == nil {
if err := triggers.MapTo(&config.Triggers); err != nil {
@@ -173,24 +162,16 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
}
file.NameMapper = mapName
config := &AercConfig{
- Bindings: defaultBindsConfig(),
-
+ Bindings: defaultBindsConfig(),
ContextualBinds: []BindingConfigContext{},
-
- General: defaultGeneralConfig(),
- Ui: defaultUiConfig(),
- ContextualUis: []UIConfigContext{},
- Viewer: defaultViewerConfig(),
-
- Statusline: StatuslineConfig{
- RenderFormat: "[%a] %S %>%T",
- Separator: " | ",
- DisplayMode: "",
- },
-
- Compose: defaultComposeConfig(),
- Templates: defaultTemplatesConfig(),
- Openers: make(map[string][]string),
+ General: defaultGeneralConfig(),
+ Ui: defaultUiConfig(),
+ ContextualUis: []UIConfigContext{},
+ Viewer: defaultViewerConfig(),
+ Statusline: defaultStatuslineConfig(),
+ Compose: defaultComposeConfig(),
+ Templates: defaultTemplatesConfig(),
+ Openers: make(map[string][]string),
}
if err := config.parseFilters(file); err != nil {
@@ -202,6 +183,9 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
if err := config.parseViewer(file); err != nil {
return nil, err
}
+ if err := config.parseStatusline(file); err != nil {
+ return nil, err
+ }
if err = config.LoadConfig(file); err != nil {
return nil, err
}
@@ -212,7 +196,6 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
return nil, err
}
- logging.Debugf("aerc.conf: [statusline] %#v", config.Statusline)
logging.Debugf("aerc.conf: [openers] %#v", config.Openers)
logging.Debugf("aerc.conf: [triggers] %#v", config.Triggers)