summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/cli/command/command.go10
-rw-r--r--cmd/cli/command/command_test.go2
-rw-r--r--cmd/cli/command/done.go8
3 files changed, 12 insertions, 8 deletions
diff --git a/cmd/cli/command/command.go b/cmd/cli/command/command.go
index 9fad960..255328b 100644
--- a/cmd/cli/command/command.go
+++ b/cmd/cli/command/command.go
@@ -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)
+ }
}
diff --git a/cmd/cli/command/command_test.go b/cmd/cli/command/command_test.go
index f0345ec..f1cd572 100644
--- a/cmd/cli/command/command_test.go
+++ b/cmd/cli/command/command_test.go
@@ -40,7 +40,7 @@ func TestCommand(t *testing.T) {
},
{
name: "done",
- args: []string{"done"},
+ args: []string{"123", "done"},
exp: "done",
},
} {
diff --git a/cmd/cli/command/done.go b/cmd/cli/command/done.go
index 986328c..aae1fab 100644
--- a/cmd/cli/command/done.go
+++ b/cmd/cli/command/done.go
@@ -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
}
}