task

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2025 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(description string, tags []string) error

Add creates a new task with the given description and tags.

func AddArgs

func AddArgs(args []string) error

AddArgs runs "task add" with the provided arguments. Each element in args is passed as a separate command-line argument, allowing the caller to specify additional modifiers like due dates or tags.

func AddLine

func AddLine(line string) error

AddLine splits the given line into shell words and runs "task add" with the resulting arguments. This allows users to pass raw Taskwarrior parameters such as "due:today" directly.

func AddTags

func AddTags(id int, tags []string) error

AddTags adds tags to the task with the given id.

func Annotate

func Annotate(id int, text string) error

Annotate adds an annotation to the task with the given id.

func Delete

func Delete(id int) error

Delete removes the task with the given id.

func Denotate

func Denotate(id int, text string) error

Denotate removes an annotation from the task with the given id. Denotate removes an annotation from the task with the given id. The annotation text is matched exactly when provided. If text is empty, the oldest annotation is removed.

func Done

func Done(id int) error

Done marks the task with the given id as completed.

func DueTasks

func DueTasks(tasks []Task, now time.Time) int

DueTasks returns the number of tasks with a due date that is not in the future.

func Edit

func Edit(id int) error

Edit opens the task in an editor for manual modification. This is a convenience wrapper around EditCmd.

func EditCmd

func EditCmd(id int) *exec.Cmd

Edit opens the task in an editor for manual modification. EditCmd returns an exec.Cmd that edits the task with the given id. The caller is responsible for running the command, typically via tea.ExecProcess so that the terminal state is properly managed.

func InProgressTasks

func InProgressTasks(tasks []Task) int

InProgressTasks returns the number of tasks that have been started and are not completed.

func RemoveTags

func RemoveTags(id int, tags []string) error

RemoveTags removes tags from the task with the given id.

func ReplaceAnnotations

func ReplaceAnnotations(id int, text string) error

ReplaceAnnotations removes all existing annotations from the task with the given id and sets a single annotation with the provided text. If text is empty, all annotations are simply removed.

func SetDebugLog

func SetDebugLog(path string) error

SetDebugLog enables logging of executed commands to the given file. Passing an empty path disables logging.

func SetDescription

func SetDescription(id int, desc string) error

SetDescription changes the description of the task with the given id.

func SetDueDate

func SetDueDate(id int, due string) error

SetDueDate sets the due date for the task with the given id.

func SetPriority

func SetPriority(id int, priority string) error

SetPriority changes the priority of the task with the given id.

func SetProject added in v0.9.2

func SetProject(id int, project string) error

SetProject changes the project of the task with the given id.

func SetRecurrence

func SetRecurrence(id int, rec string) error

SetRecurrence sets the recurrence for the task with the given id.

func SetStatus

func SetStatus(id int, status string) error

SetStatus changes the status of the task with the given id.

func SetStatusUUID

func SetStatusUUID(uuid, status string) error

SetStatusUUID changes the status of the task with the given UUID.

func SetTags

func SetTags(id int, tags []string) error

SetTags sets the tags of the task with the given id to exactly the provided set. Tags not present will be removed and new tags added as needed.

func SortTasks

func SortTasks(tasks []Task)

SortTasks orders tasks by start status, priority, due date, tag names and id. Started tasks are always placed before non-started ones. Tasks without a due date are placed after tasks with a due date. Overdue tasks are placed at the very top regardless of other properties.

The sort order is: 1. Overdue tasks (oldest due date first) 2. Started tasks (not completed) 3. High priority tasks 4. Tasks with earlier due dates 5. Tasks sorted alphabetically by tags 6. Tasks sorted by ID (oldest first)

func Start

func Start(id int) error

Start begins the task with the given id.

func Stop

func Stop(id int) error

Stop stops the task with the given id.

func TotalTasks

func TotalTasks(tasks []Task) int

TotalTasks returns the number of tasks provided.

Types

type Annotation

type Annotation struct {
	Entry       string `json:"entry"`
	Description string `json:"description"`
}

Task represents a taskwarrior task as returned by `task export`.

type Task

type Task struct {
	ID          int          `json:"id"`
	UUID        string       `json:"uuid"`
	Description string       `json:"description"`
	Project     string       `json:"project"`
	Tags        []string     `json:"tags"`
	Status      string       `json:"status"`
	Start       string       `json:"start"`
	Entry       string       `json:"entry"`
	Due         string       `json:"due"`
	Priority    string       `json:"priority"`
	Recur       string       `json:"recur"`
	Urgency     float64      `json:"urgency"`
	Annotations []Annotation `json:"annotations"`
}

func Export

func Export(filters ...string) ([]Task, error)

Export retrieves all tasks using `task export rc.json.array=off` and parses the JSON output into a slice of Task structs. Export retrieves tasks using `task <filter> export rc.json.array=off` and parses the JSON output into a slice of Task structs. Optional filter arguments are passed directly to the `task` command before `export`.

Jump to

Keyboard shortcuts

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