aerc/cmd/aerc/main.go

41 lines
787 B
Go
Raw Normal View History

2018-01-10 00:30:46 +01:00
package main
import (
"fmt"
2018-01-10 14:35:26 +01:00
"time"
2018-01-10 01:18:19 +01:00
"git.sr.ht/~sircmpwn/aerc2/config"
"git.sr.ht/~sircmpwn/aerc2/worker"
"git.sr.ht/~sircmpwn/aerc2/worker/types"
2018-01-10 00:30:46 +01:00
)
func main() {
2018-01-10 17:19:45 +01:00
conf, err := config.LoadConfig(nil)
if err != nil {
2018-01-10 01:18:19 +01:00
panic(err)
}
2018-01-10 17:19:45 +01:00
var workers []worker.Worker
2018-01-10 03:24:50 +01:00
for _, account := range conf.Accounts {
2018-01-10 17:19:45 +01:00
work, err := worker.NewWorker(account.Source)
if err != nil {
2018-01-10 03:24:50 +01:00
panic(err)
}
fmt.Printf("Initializing worker %s\n", account.Name)
go work.Run()
work.PostAction(types.Configure{Config: account})
workers = append(workers, work)
}
for {
2018-01-10 14:35:26 +01:00
activity := false
2018-01-10 03:24:50 +01:00
for _, worker := range workers {
if msg := worker.GetMessage(); msg != nil {
2018-01-10 14:35:26 +01:00
activity = true
2018-01-10 03:24:50 +01:00
fmt.Printf("<- %T\n", msg)
}
}
2018-01-10 14:35:26 +01:00
if !activity {
time.Sleep(100 * time.Millisecond)
}
}
2018-01-10 00:30:46 +01:00
}