aboutsummaryrefslogtreecommitdiff
path: root/cmd/aerc/main.go
blob: d5d08973f1f3a6bfe66caf7d9871346cd07f08ec (plain)
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
package main

import (
	"fmt"

	"git.sr.ht/~sircmpwn/aerc2/config"
	"git.sr.ht/~sircmpwn/aerc2/worker"
	"git.sr.ht/~sircmpwn/aerc2/worker/types"
)

func main() {
	var (
		conf *config.AercConfig
		err  error
	)
	if conf, err = config.LoadConfig(nil); err != nil {
		panic(err)
	}
	workers := make([]worker.Worker, 0)
	for _, account := range conf.Accounts {
		var work worker.Worker
		if work, err = worker.NewWorker(account.Source); err != nil {
			panic(err)
		}
		fmt.Printf("Initializing worker %s\n", account.Name)
		go work.Run()
		work.PostAction(types.Configure{Config: account})
		workers = append(workers, work)
	}
	for {
		for _, worker := range workers {
			if msg := worker.GetMessage(); msg != nil {
				fmt.Printf("<- %T\n", msg)
			}
		}
	}
}