blob: e246ea64fcce50f5db1dc6fb9098e2e2ee13c6f3 (
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
30
31
32
33
34
35
36
37
38
39
40
|
package config
import (
"fmt"
"strings"
"git.sr.ht/~rjarry/aerc/log"
"github.com/go-ini/ini"
"github.com/google/shlex"
)
type Opener struct {
Mime string
Args []string
}
var Openers []Opener
func parseOpeners(file *ini.File) error {
openers, err := file.GetSection("openers")
if err != nil {
goto out
}
for _, key := range openers.Keys() {
mime := strings.ToLower(key.Name())
if args, err := shlex.Split(key.Value()); err != nil {
return err
} else {
if len(args) == 0 {
return fmt.Errorf("opener command empty for %s", mime)
}
Openers = append(Openers, Opener{Mime: mime, Args: args})
}
}
out:
log.Debugf("aerc.conf: [openers] %#v", Openers)
return nil
}
|