diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/config.go | 20 | ||||
-rw-r--r-- | config/triggers.go | 19 |
2 files changed, 20 insertions, 19 deletions
diff --git a/config/config.go b/config/config.go index 20e28bd2..049b305f 100644 --- a/config/config.go +++ b/config/config.go @@ -15,11 +15,6 @@ import ( "git.sr.ht/~rjarry/aerc/logging" ) -type TriggersConfig struct { - NewEmail string `ini:"new-email"` - ExecuteCommand func(command []string) error -} - type AercConfig struct { Bindings BindingConfig ContextualBinds []BindingConfigContext @@ -115,16 +110,6 @@ func installTemplate(root, name string) error { return nil } -func (config *AercConfig) LoadConfig(file *ini.File) error { - if triggers, err := file.GetSection("triggers"); err == nil { - if err := triggers.MapTo(&config.Triggers); err != nil { - return err - } - } - - return nil -} - func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) { if root == nil { _root := path.Join(xdg.ConfigHome(), "aerc") @@ -177,7 +162,7 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) { if err := config.parseOpeners(file); err != nil { return nil, err } - if err = config.LoadConfig(file); err != nil { + if err := config.parseTriggers(file); err != nil { return nil, err } if err := config.parseUi(file); err != nil { @@ -186,9 +171,6 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) { if err := config.parseGeneral(file); err != nil { return nil, err } - - logging.Debugf("aerc.conf: [triggers] %#v", config.Triggers) - if err := config.parseTemplates(file); err != nil { return nil, err } diff --git a/config/triggers.go b/config/triggers.go index edaea45f..af400501 100644 --- a/config/triggers.go +++ b/config/triggers.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" + "github.com/go-ini/ini" "github.com/google/shlex" "git.sr.ht/~rjarry/aerc/lib/format" @@ -11,6 +12,24 @@ import ( "git.sr.ht/~rjarry/aerc/models" ) +type TriggersConfig struct { + NewEmail string `ini:"new-email"` + ExecuteCommand func(command []string) error +} + +func (config *AercConfig) parseTriggers(file *ini.File) error { + triggers, err := file.GetSection("triggers") + if err != nil { + goto out + } + if err := triggers.MapTo(&config.Triggers); err != nil { + return err + } +out: + logging.Debugf("aerc.conf: [triggers] %#v", config.Triggers) + return nil +} + func (trig *TriggersConfig) ExecTrigger(triggerCmd string, triggerFmt func(string) (string, error), ) error { |