gte/cmd/cli/command/project.go

43 lines
843 B
Go
Raw Normal View History

2021-08-20 08:18:26 +02:00
package command
import (
"strings"
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"
2021-08-20 08:18:26 +02:00
)
type Project struct {
lister *process.List
}
func NewProject(conf *configuration.Configuration, cmdArgs []string) (*Project, error) {
local, err := storage.NewSqlite(conf.Sqlite())
if err != nil {
return &Project{}, err
}
if len(cmdArgs) < 1 {
return &Project{}, ErrInvalidAmountOfArgs
}
reqs := process.ListReqs{
Project: strings.ToLower(cmdArgs[0]),
ApplyUpdates: true,
2021-08-20 08:18:26 +02:00
}
lister := process.NewList(local, reqs)
return &Project{
lister: lister,
}, nil
}
func (p *Project) Do() string {
res, err := p.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 08:18:26 +02:00
}