gte/cmd/cli/command/week.go

39 lines
753 B
Go
Raw Normal View History

2021-08-20 11:27:12 +02:00
package command
import (
2021-09-19 11:59:26 +02:00
"ewintr.nl/gte/cmd/cli/format"
"ewintr.nl/gte/internal/configuration"
"ewintr.nl/gte/internal/process"
"ewintr.nl/gte/internal/storage"
"ewintr.nl/gte/internal/task"
2021-08-20 11:27:12 +02:00
)
type Week struct {
lister *process.List
}
func NewWeek(conf *configuration.Configuration) (*Week, error) {
local, err := storage.NewSqlite(conf.Sqlite())
if err != nil {
return &Week{}, err
}
reqs := process.ListReqs{
Due: task.Today.Add(7),
IncludeBefore: true,
ApplyUpdates: true,
2021-08-20 11:27:12 +02:00
}
return &Week{
lister: process.NewList(local, reqs),
}, nil
}
func (w *Week) Do() string {
res, err := w.lister.Process()
if err != nil {
return format.FormatError(err)
}
2022-06-05 13:00:23 +02:00
return format.FormatTaskTable(res.Tasks, format.COL_ALL)
2021-08-20 11:27:12 +02:00
}