gte/cmd/cli/command/new.go

38 lines
759 B
Go
Raw Normal View History

2021-09-04 12:20:35 +02:00
package command
import (
"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"
)
// New sends an action to the NEW folder so it can be updated to a real task later
type New struct {
newer *process.New
}
func NewNew(conf *configuration.Configuration, cmdArgs []string) (*New, error) {
local, err := storage.NewSqlite(conf.Sqlite())
if err != nil {
return &New{}, err
}
update, err := format.ParseTaskFieldArgs(cmdArgs)
if err != nil {
return &New{}, err
}
return &New{
newer: process.NewNew(local, update),
}, nil
}
func (n *New) Do() string {
if err := n.newer.Process(); err != nil {
return format.FormatError(err)
}
return ""
}