gte/cmd/process-inbox/main.go

36 lines
890 B
Go
Raw Normal View History

2021-01-29 12:29:23 +01:00
package main
import (
2021-05-15 11:19:28 +02:00
"flag"
2021-01-29 12:29:23 +01:00
"os"
2021-05-13 08:15:14 +02:00
"git.ewintr.nl/go-kit/log"
2021-05-15 11:19:28 +02:00
"git.ewintr.nl/gte/internal/configuration"
2021-05-13 08:15:14 +02:00
"git.ewintr.nl/gte/internal/process"
2021-05-13 09:47:06 +02:00
"git.ewintr.nl/gte/internal/task"
"git.ewintr.nl/gte/pkg/mstore"
2021-01-29 12:29:23 +01:00
)
func main() {
2021-05-13 08:15:14 +02:00
logger := log.New(os.Stdout).WithField("cmd", "process-inbox")
2021-01-29 12:29:23 +01:00
2021-05-15 11:19:28 +02:00
configPath := flag.String("c", "~/.config/gte/gte.conf", "path to configuration file")
flag.Parse()
configFile, err := os.Open(*configPath)
if err != nil {
logger.WithErr(err).Error("could not open config file")
os.Exit(1)
}
config := configuration.New(configFile)
msgStore := mstore.NewIMAP(config.IMAP())
2021-06-25 08:33:14 +02:00
inboxProcessor := process.NewInbox(task.NewRemoteRepository(msgStore))
2021-05-15 11:19:28 +02:00
2021-05-13 08:15:14 +02:00
result, err := inboxProcessor.Process()
2021-01-29 12:29:23 +01:00
if err != nil {
2021-05-13 08:15:14 +02:00
logger.WithErr(err).Error("unable to process inbox")
os.Exit(1)
2021-01-29 19:40:46 +01:00
}
2021-05-15 11:46:03 +02:00
logger.WithField("result", result).Info("finished processing inbox")
2021-01-29 12:29:23 +01:00
}