aboutsummaryrefslogtreecommitdiffstats
path: root/config/openers.go
blob: c62ec974e8045d63e17d7d48d2f24d46276e0548 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package config

import (
	"strings"

	"git.sr.ht/~rjarry/aerc/log"
	"github.com/go-ini/ini"
	"github.com/google/shlex"
)

func (config *AercConfig) parseOpeners(file *ini.File) error {
	openers, err := file.GetSection("openers")
	if err != nil {
		goto out
	}

	for mimeType, command := range openers.KeysHash() {
		mimeType = strings.ToLower(mimeType)
		if args, err := shlex.Split(command); err != nil {
			return err
		} else {
			config.Openers[mimeType] = args
		}
	}

out:
	log.Debugf("aerc.conf: [openers] %#v", config.Openers)
	return nil
}