swapped done args

This commit is contained in:
Erik Winter 2021-07-28 07:09:39 +02:00
parent c44a537e70
commit 05db15c62d
3 changed files with 12 additions and 8 deletions

View File

@ -37,8 +37,6 @@ func Parse(args []string, conf *configuration.Configuration) (Command, error) {
return NewTomorrow(conf)
case "new":
return NewNew(conf, cmdArgs)
case "done":
return NewDone(conf, cmdArgs)
default:
return NewEmpty()
}
@ -49,5 +47,11 @@ func parseTaskCommand(id int, tArgs []string, conf *configuration.Configuration)
return NewShow(id, conf)
}
return NewEmpty()
cmd, _ := tArgs[0], tArgs[1:]
switch cmd {
case "done":
return NewDone(id, conf)
default:
return NewShow(id, conf)
}
}

View File

@ -40,7 +40,7 @@ func TestCommand(t *testing.T) {
},
{
name: "done",
args: []string{"done"},
args: []string{"123", "done"},
exp: "done",
},
} {

View File

@ -17,7 +17,7 @@ type Done struct {
func (d *Done) Cmd() string { return "done" }
func NewDone(conf *configuration.Configuration, cmdArgs []string) (*Done, error) {
func NewDone(id int, conf *configuration.Configuration) (*Done, error) {
local, err := storage.NewSqlite(conf.Sqlite())
if err != nil {
return &Done{}, err
@ -30,9 +30,9 @@ func NewDone(conf *configuration.Configuration, cmdArgs []string) (*Done, error)
return &Done{}, err
}
var tId string
for id, localId := range localIds {
if fmt.Sprintf("%d", localId) == cmdArgs[0] {
tId = id
for remoteId, localId := range localIds {
if localId == id {
tId = remoteId
break
}
}