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,
|
2021-09-07 06:50:30 +02:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
|
|
|
return format.FormatTaskTable(res.Tasks)
|
|
|
|
}
|