aboutsummaryrefslogtreecommitdiffstats
path: root/config/triggers.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-11-15 22:55:55 +0100
committerRobin Jarry <robin@jarry.cc>2022-11-16 16:12:13 +0100
commit9db3710dd73b6949321a028b4dc2dc2277e97ce0 (patch)
tree893afee9a3057cb10a0f0ae595e4c94f27026662 /config/triggers.go
parentc016a51900bfb26b536621039320f2485061dfc2 (diff)
downloadaerc-9db3710dd73b6949321a028b4dc2dc2277e97ce0.tar.gz
config: move [triggers] parsing in proper file
The config.go file is getting too big. Move the aerc.conf [triggers] section parsing logic into a dedicated triggers.go file. No functional change. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'config/triggers.go')
-rw-r--r--config/triggers.go19
1 files changed, 19 insertions, 0 deletions
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 {