diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-01-09 21:24:50 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-01-09 21:31:36 -0500 |
commit | b5d5e0dbedee34bd5d3edf13616f055d4f227d36 (patch) | |
tree | d4353b88a830a29c570b0a54adcda2126427fc95 /cmd | |
parent | 6394e386c2a88c3b376cd422a7b7ce5ae7534984 (diff) | |
download | aerc-b5d5e0dbedee34bd5d3edf13616f055d4f227d36.tar.gz |
Parse account configuration
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/aerc/main.go | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/cmd/aerc/main.go b/cmd/aerc/main.go index 2627a714..d5d08973 100644 --- a/cmd/aerc/main.go +++ b/cmd/aerc/main.go @@ -10,19 +10,28 @@ import ( func main() { var ( - c *config.AercConfig - err error + conf *config.AercConfig + err error ) - if c, err = config.LoadConfig(nil); err != nil { + if conf, err = config.LoadConfig(nil); err != nil { panic(err) } - fmt.Printf("%+v\n", *c) - w := worker.NewWorker("") - go w.Run() - w.PostAction(types.Ping{}) + 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 { - if msg := w.GetMessage(); msg != nil { - fmt.Printf("<- %T: %v\n", msg, msg) + for _, worker := range workers { + if msg := worker.GetMessage(); msg != nil { + fmt.Printf("<- %T\n", msg) + } } } } |