gte/cmd/cli/command/new.go

38 lines
764 B
Go
Raw Normal View History

2021-09-04 12:20:35 +02:00
package command
import (
2024-09-17 07:33:26 +02:00
"go-mod.ewintr.nl/gte/cmd/cli/format"
"go-mod.ewintr.nl/gte/internal/configuration"
"go-mod.ewintr.nl/gte/internal/process"
"go-mod.ewintr.nl/gte/internal/storage"
2021-09-04 12:20:35 +02:00
)
// 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
}
2022-09-28 08:49:25 +02:00
update, err := ParseTaskFieldArgs(cmdArgs)
2021-09-04 12:20:35 +02:00
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 ""
}