Skip to content

Commit

Permalink
Merge pull request #225 from HacDan/issue216
Browse files Browse the repository at this point in the history
fix(issue-#216): resolves modifying and setting date on task creation
  • Loading branch information
kenliu authored Apr 16, 2023
2 parents c1308b3 + 515e1e1 commit 15ce568
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions add.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"strings"

todoist "github.com/sachaos/todoist/lib"
"github.com/sachaos/todoist/lib"
"github.com/urfave/cli/v2"
)

Expand Down Expand Up @@ -38,7 +38,8 @@ func Add(c *cli.Context) error {
return names
}(c.String("label-names"))

item.DateString = c.String("date")
item.Due = &todoist.Due{String: c.String("date")}

item.AutoReminder = c.Bool("reminder")

if err := client.AddItem(context.Background(), item); err != nil {
Expand Down
6 changes: 6 additions & 0 deletions lib/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ func (item Item) AddParam() interface{} {
if item.ProjectID != "" {
param["project_id"] = item.ProjectID
}
if item.Due != nil {
param["due"] = item.Due
}
param["auto_reminder"] = item.AutoReminder

return param
Expand All @@ -193,6 +196,9 @@ func (item Item) UpdateParam() interface{} {
if item.Priority != 0 {
param["priority"] = item.Priority
}
if item.Due != nil {
param["due"] = item.Due
}
return param
}

Expand Down
3 changes: 2 additions & 1 deletion modify.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"strings"

"github.com/sachaos/todoist/lib"
"github.com/urfave/cli/v2"
)

Expand Down Expand Up @@ -34,7 +35,7 @@ func Modify(c *cli.Context) error {
return names
}(c.String("label-names"))

item.DateString = c.String("date")
item.Due = &todoist.Due{String: c.String("date")}

projectID := c.String("project-id")
if projectID == "" {
Expand Down

0 comments on commit 15ce568

Please sign in to comment.