gte/cmd/cli/command/inbox.go

33 lines
648 B
Go
Raw Normal View History

2021-08-20 10:55:11 +02:00
package command
import (
"fmt"
"git.ewintr.nl/gte/cmd/cli/format"
"git.ewintr.nl/gte/internal/configuration"
"git.ewintr.nl/gte/internal/process"
"git.ewintr.nl/gte/internal/storage"
"git.ewintr.nl/gte/pkg/mstore"
)
type Inbox struct {
inboxer *process.Inbox
}
func NewInbox(conf *configuration.Configuration) (*Inbox, error) {
remote := storage.NewRemoteRepository(mstore.NewIMAP(conf.IMAP()))
return &Inbox{
inboxer: process.NewInbox(remote),
}, nil
}
func (i *Inbox) Do() string {
res, err := i.inboxer.Process()
if err != nil {
return format.FormatError(err)
}
2021-09-04 19:47:36 +02:00
return fmt.Sprintf("processed %d tasks\n\n", res.Count)
2021-08-20 10:55:11 +02:00
}