From fbc2a3d40071b504a5f647ba7e065bc1f6151f60 Mon Sep 17 00:00:00 2001 From: Erik Winter Date: Mon, 16 Aug 2021 06:54:45 +0200 Subject: [PATCH] renamed new to add --- cmd/cli/command/{new.go => add.go} | 20 +++++++++----------- cmd/cli/command/command.go | 4 ++-- 2 files changed, 11 insertions(+), 13 deletions(-) rename cmd/cli/command/{new.go => add.go} (59%) diff --git a/cmd/cli/command/new.go b/cmd/cli/command/add.go similarity index 59% rename from cmd/cli/command/new.go rename to cmd/cli/command/add.go index 62cef85..a196ba9 100644 --- a/cmd/cli/command/new.go +++ b/cmd/cli/command/add.go @@ -1,6 +1,8 @@ package command import ( + "strings" + "git.ewintr.nl/gte/cmd/cli/format" "git.ewintr.nl/gte/internal/configuration" "git.ewintr.nl/gte/internal/storage" @@ -8,28 +10,24 @@ import ( "git.ewintr.nl/gte/pkg/msend" ) -// New sends an action to the NEW folder so it can be updated to a real task later -type New struct { +// Add sends an action to the NEW folder so it can be updated to a real task later +type Add struct { disp *storage.Dispatcher action string } -func (n *New) Cmd() string { return "new" } - -func NewNew(conf *configuration.Configuration, cmdArgs []string) (*New, error) { - if len(cmdArgs) != 1 { - return &New{}, ErrInvalidAmountOfArgs - } +func (n *Add) Cmd() string { return "new" } +func NewAdd(conf *configuration.Configuration, cmdArgs []string) (*Add, error) { disp := storage.NewDispatcher(msend.NewSSLSMTP(conf.SMTP())) - return &New{ + return &Add{ disp: disp, - action: cmdArgs[0], + action: strings.Join(cmdArgs, " "), }, nil } -func (n *New) Do() string { +func (n *Add) Do() string { if err := n.disp.Dispatch(&task.Task{Action: n.action}); err != nil { return format.FormatError(err) } diff --git a/cmd/cli/command/command.go b/cmd/cli/command/command.go index 992babe..4684f95 100644 --- a/cmd/cli/command/command.go +++ b/cmd/cli/command/command.go @@ -38,8 +38,8 @@ func Parse(args []string, conf *configuration.Configuration) (Command, error) { return NewToday(conf) case "tomorrow": return NewTomorrow(conf) - case "new": - return NewNew(conf, cmdArgs) + case "add": + return NewAdd(conf, cmdArgs) default: return NewEmpty() }