tasks

package
v0.0.217 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package tasks provides a client for managing Google Tasks.

This package wraps the Google Tasks API (tasks/v1) and provides functionality for:

  • Managing task lists (list, get, create, update, delete)
  • Managing tasks (list, get, create, update, delete, complete, move)
  • Filtering tasks by due date and completion status
  • Creating subtasks and organizing task hierarchies

The client supports both CLI and MCP server modes, with multi-account authentication through the unified Google OAuth2 system.

Authentication

The client uses the same OAuth2 token system as other Google services (Gmail, Calendar, etc.). Tokens are stored per-account in the user's cache directory and provide access to:

  • Google Tasks (read/write)

For HTTP/SSE transports: OAuth is handled automatically by the MCP client. For STDIO transport: Tokens are loaded from the file system (~/.cache/inboxfewer/).

Example Usage

// Create a client for the default account
client, err := tasks.NewClient(ctx)
if err != nil {
    log.Fatal(err)
}

// List all task lists
lists, err := client.ListTaskLists()
if err != nil {
    log.Fatal(err)
}

// Create a new task
task, err := client.CreateTask(lists[0].ID, tasks.TaskInput{
    Title: "Complete project",
    Notes: "Finish implementation and testing",
    Due:   time.Now().AddDate(0, 0, 7), // Due in 7 days
})
if err != nil {
    log.Fatal(err)
}

// Complete a task
completed, err := client.CompleteTask(lists[0].ID, task.ID)
if err != nil {
    log.Fatal(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasToken

func HasToken() bool

HasToken checks if a valid OAuth token exists for the default account

func HasTokenForAccount

func HasTokenForAccount(account string) bool

HasTokenForAccount checks if a valid OAuth token exists for the specified account

func HasTokenForAccountWithProvider added in v0.0.27

func HasTokenForAccountWithProvider(account string, provider google.TokenProvider) bool

HasTokenForAccountWithProvider checks if a valid OAuth token exists for the specified account

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps the Google Tasks service

func NewClient

func NewClient(ctx context.Context) (*Client, error)

NewClient creates a new Tasks client with OAuth2 authentication for the default account For CLI usage, it will prompt for auth code via stdin if no token exists For MCP usage, it will return an error if no token exists

func NewClientForAccount

func NewClientForAccount(ctx context.Context, account string) (*Client, error)

NewClientForAccount creates a new Tasks client with OAuth2 authentication for a specific account Uses the default file-based token provider for backward compatibility

func NewClientForAccountWithProvider added in v0.0.27

func NewClientForAccountWithProvider(ctx context.Context, account string, tokenProvider google.TokenProvider) (*Client, error)

NewClientForAccountWithProvider creates a new Tasks client with OAuth2 authentication for a specific account The OAuth token is retrieved from the provided token provider

func NewClientWithProvider added in v0.0.27

func NewClientWithProvider(ctx context.Context, provider google.TokenProvider) (*Client, error)

NewClientWithProvider creates a new Tasks client with OAuth2 authentication for the default account using the provided token provider

func (*Client) Account

func (c *Client) Account() string

Account returns the account name this client is associated with

func (*Client) ClearCompletedTasks

func (c *Client) ClearCompletedTasks(taskListID string) error

ClearCompletedTasks clears all completed tasks from a task list

func (*Client) CompleteTask

func (c *Client) CompleteTask(taskListID, taskID string) (*Task, error)

CompleteTask marks a task as completed

func (*Client) CreateTask

func (c *Client) CreateTask(taskListID string, input TaskInput) (*Task, error)

CreateTask creates a new task

func (*Client) CreateTaskList

func (c *Client) CreateTaskList(title string) (*TaskList, error)

CreateTaskList creates a new task list

func (*Client) DeleteTask

func (c *Client) DeleteTask(taskListID, taskID string) error

DeleteTask deletes a task

func (*Client) DeleteTaskList

func (c *Client) DeleteTaskList(taskListID string) error

DeleteTaskList deletes a task list

func (*Client) GetTask

func (c *Client) GetTask(taskListID, taskID string) (*Task, error)

GetTask retrieves a specific task by ID

func (*Client) GetTaskList

func (c *Client) GetTaskList(taskListID string) (*TaskList, error)

GetTaskList retrieves a specific task list by ID

func (*Client) ListTaskLists

func (c *Client) ListTaskLists() ([]TaskList, error)

ListTaskLists lists all task lists for the authenticated user

func (*Client) ListTasks

func (c *Client) ListTasks(taskListID string, showCompleted bool, dueMin, dueMax time.Time) ([]Task, error)

ListTasks lists tasks in a task list Options: - showCompleted: if true, includes completed tasks - dueMin: only tasks with due date after this time - dueMax: only tasks with due date before this time

func (*Client) MoveTask

func (c *Client) MoveTask(taskListID, taskID string, parent, previous string) (*Task, error)

MoveTask moves a task to a different position or parent

func (*Client) UpdateTask

func (c *Client) UpdateTask(taskListID, taskID string, input TaskInput) (*Task, error)

UpdateTask updates an existing task

func (*Client) UpdateTaskList

func (c *Client) UpdateTaskList(taskListID, title string) (*TaskList, error)

UpdateTaskList updates a task list's title

type Link struct {
	Type        string // "email" or other types
	Description string
	Link        string
}

Link represents a related link in a task

type Task

type Task struct {
	ID        string
	Title     string
	Notes     string
	Status    string // "needsAction" or "completed"
	Due       time.Time
	Completed time.Time
	Parent    string // Parent task ID for subtasks
	Position  string // Position in the list
	Links     []Link // Related links
}

Task represents a Google Tasks task

type TaskInput

type TaskInput struct {
	Title    string
	Notes    string
	Status   string // "needsAction" or "completed"
	Due      time.Time
	Parent   string // Parent task ID for subtasks
	Previous string // Previous sibling task ID for positioning
}

TaskInput represents the input for creating or updating a task

type TaskList

type TaskList struct {
	ID      string
	Title   string
	Updated time.Time
}

TaskList represents a Google Tasks task list

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL