diff options
author | Robin Jarry <robin@jarry.cc> | 2022-11-15 00:22:55 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-11-16 16:12:01 +0100 |
commit | eb10c328fd8953f4a2cc7d22126f4214a57c9261 (patch) | |
tree | 76381ba24bdb33c7cb0cba4edfa81cf6bfa11996 /config/config.go | |
parent | 21f82053075b320015ac622c683aafeac2b0a041 (diff) | |
download | aerc-eb10c328fd8953f4a2cc7d22126f4214a57c9261.tar.gz |
config: move [general] parsing in separate file
The config.go file is getting too big. Move the aerc.conf [general]
section parsing logic into a dedicated general.go file.
No functional change.
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.go | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/config/config.go b/config/config.go index 16d07e3f..d889393a 100644 --- a/config/config.go +++ b/config/config.go @@ -18,12 +18,6 @@ import ( "git.sr.ht/~rjarry/aerc/logging" ) -type GeneralConfig struct { - DefaultSavePath string `ini:"default-save-path"` - PgpProvider string `ini:"pgp-provider"` - UnsafeAccountsConf bool `ini:"unsafe-accounts-conf"` -} - const ( FILTER_MIMETYPE = iota FILTER_HEADER @@ -255,21 +249,6 @@ func (config *AercConfig) LoadConfig(file *ini.File) error { return nil } -func validatePgpProvider(section *ini.Section) error { - m := map[string]bool{ - "gpg": true, - "internal": true, - } - for key, val := range section.KeysHash() { - if key == "pgp-provider" { - if !m[strings.ToLower(val)] { - return fmt.Errorf("%v must be either 'gpg' or 'internal'", key) - } - } - } - return nil -} - func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) { if root == nil { _root := path.Join(xdg.ConfigHome(), "aerc") @@ -299,11 +278,7 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) { ContextualBinds: []BindingConfigContext{}, - General: GeneralConfig{ - PgpProvider: "internal", - UnsafeAccountsConf: false, - }, - + General: defaultGeneralConfig(), Ui: defaultUiConfig(), ContextualUis: []UIConfigContext{}, @@ -344,17 +319,10 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) { if err := config.parseUi(file); err != nil { return nil, err } - - if ui, err := file.GetSection("general"); err == nil { - if err := ui.MapTo(&config.General); err != nil { - return nil, err - } - if err := validatePgpProvider(ui); err != nil { - return nil, err - } + if err := config.parseGeneral(file); err != nil { + return nil, err } - logging.Debugf("aerc.conf: [general] %#v", config.General) logging.Debugf("aerc.conf: [statusline] %#v", config.Statusline) logging.Debugf("aerc.conf: [viewer] %#v", config.Viewer) logging.Debugf("aerc.conf: [compose] %#v", config.Compose) |