aboutsummaryrefslogtreecommitdiff
path: root/cmd/aerc/main.go
blob: 845d17677408e30240493b7d6557ea5c74c093c9 (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
38
39
40
41
42
43
package main

import (
	"fmt"
	"time"

	"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 {
		activity := false
		for _, worker := range workers {
			if msg := worker.GetMessage(); msg != nil {
				activity = true
				fmt.Printf("<- %T\n", msg)
			}
		}
		if !activity {
			time.Sleep(100 * time.Millisecond)
		}
	}
}