Giter VIP home page Giter VIP logo

go-todoist's Introduction

go-todoist

Go Report Card CircleCI

Unofficial CLI and library for todoist.

Install

Binary

Go to https://github.com/kobtea/go-todoist/releases

Building from source

$ go get -d github.com/kobtea/go-todoist
$ cd $GOPATH/src/github.com/kobtea/go-todoist
$ make build

Usage

$ todoist help
Command line tool for todoist.

Usage:
  todoist [command]

Available Commands:
  completion  generate completion script
  config      configure about this CLI
  filter      subcommand for filter
  help        Help about any command
  inbox       show inbox tasks
  item        subcommand for item
  label       subcommand for label
  next        show next 7 days tasks
  project     subcommand for project
  review      show completed items
  sync        Syncronize origin server
  today       show today's tasks
  version     show version of go-todoist

Flags:
      --config string   config file (default is $HOME/.todoist.yaml)
  -h, --help            help for todoist

Use "todoist [command] --help" for more information about a command.

Configure your API token of todoist.
The location of API token is Todoist > Settings > Integrations > API token.

$ todoist config
todoist token (default: ): YOUR_TOKEN_HERE
write config to /home/kobtea/.go-todoist/config.json

Sync contents.

$ todoist sync

Enjoy.

$ todoist item add hello go-todoist
$ todoist inbox

Bash and zsh completion are supported ;)
Completion requires fzf.

# bash
$ . <(todoist completion bash)
# zsh
$ . <(todoist completion zsh)

As a Library

This library supports sync api v8.
Implementation refers to python official library.

sample

package main

import (
	"context"
	"github.com/kobtea/go-todoist/todoist"
	"os"
)

func main() {
	token := os.Getenv("TODOIST_TOKEN")
	cli, _ := todoist.NewClient("", token, "*", "", nil)
	ctx := context.Background()

	// sync contents
	cli.FullSync(ctx, []todoist.Command{})

	// add item
	item, _ := todoist.NewItem("hello go-todoist", &todoist.NewItemOpts{})
	cli.Item.Add(*item)
	cli.Commit(ctx)
}

License

MIT

go-todoist's People

Contributors

kobtea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

go-todoist's Issues

No longer works

Clicking from the README to the API docs shows this message.

DEPRECATED: This version of the Sync API (v8) is deprecated and will be removed after Nov 30. Please refer to the v9 documentation

Running todoist sync results in Error: failed to sync, status code: 410, command: []

Due does not get updated

The due string passed seems to be ignored, although no error is triggered.

For example:

# todoist item update 3735676838 --due="2020-06-01"
success to update the item
3735676838 2020-03-06(Fri) 17:30

Is the format correct?

Items aren't being updated

I'm writing a bot to handle managing todoist tasks created from jira issues. When I try to update the date or priority, neither actually makes the change.

Here's the section of code that does the interaction with todoist. Let me know if you need to see the whole program, though:

func createTodoistTaskfromJiraIssues(todoistClient *todoist.Client, jiraClient *jira.Client) {
    ctx := context.Background()
    if err := todoistClient.FullSync(ctx, []todoist.Command{}); err != nil {
        log.Fatal(err)
    }

    projects := todoistClient.Project.FindByName(config("todoist-project"))

    issues, _, err := jiraClient.Issue.Search("assignee = currentUser() AND resolution = Unresolved", nil)
    if err != nil {
        log.Fatal(err)
    }

    for _, issue := range issues {
        content := fmt.Sprintf("[%v] %v", issue.Key, issue.Fields.Summary)
        existing := todoistClient.Item.FindByContent(content)
        if len(existing) > 0 {
            fmt.Println("Found existing tasks, updating...")
            for _, task := range existing {
                if task.IsOverDueDate() {
                    task.DateString = "tod"
                }
                task.Priority = todoistPriority(issue.Fields.Priority.Name)
                _, err := todoistClient.Item.Update(task)
                if err != nil {
                    log.Fatal(err)
                }
            }
        } else {
            fmt.Println("Creating new task...")
            todoistClient.Item.Add(todoist.Item{
                ProjectID:  projects[0].ID,
                Content:    content,
                DateString: "tod",
                Priority:   todoistPriority(issue.Fields.Priority.Name),
            })
        }
    }

    if err = todoistClient.Commit(ctx); err != nil {
        log.Fatal(err)
    }
}

Let me know what you think, thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.