Documentation
¶
Overview ¶
Package tasks serves the Taskwarrior operations of the web API behind `workflow --web`: the task list, the event stream's summary of your tasks, and the writes on them, over the seam the terminal's Tasks pane asks. It changes with the tool it drives, so it sits apart from the rest of the server, which embeds its Handlers and hands it what it takes from the server through a Kit.
Index ¶
- Variables
- type Handlers
- func (h *Handlers) AddTask(ctx context.Context, request api.AddTaskRequestObject) (api.AddTaskResponseObject, error)
- func (h *Handlers) AnnotateTask(ctx context.Context, request api.AnnotateTaskRequestObject) (api.AnnotateTaskResponseObject, error)
- func (h *Handlers) CompleteTask(ctx context.Context, request api.CompleteTaskRequestObject) (api.CompleteTaskResponseObject, error)
- func (h *Handlers) ListTasks(ctx context.Context, _ api.ListTasksRequestObject) (api.ListTasksResponseObject, error)
- func (h *Handlers) ModifyTask(ctx context.Context, request api.ModifyTaskRequestObject) (api.ModifyTaskResponseObject, error)
- func (h *Handlers) StartTask(ctx context.Context, request api.StartTaskRequestObject) (api.StartTaskResponseObject, error)
- func (h *Handlers) StopTask(ctx context.Context, request api.StopTaskRequestObject) (api.StopTaskResponseObject, error)
- func (h *Handlers) Summary(ctx context.Context) api.TasksSummary
- func (h *Handlers) SyncTasks(ctx context.Context, _ api.SyncTasksRequestObject) (api.SyncTasksResponseObject, error)
- func (h *Handlers) TrackIssue(ctx context.Context, request api.TrackIssueRequestObject) (api.TrackIssueResponseObject, error)
- func (h *Handlers) UndoTasks(ctx context.Context, _ api.UndoTasksRequestObject) (api.UndoTasksResponseObject, error)
- type Kit
- type Seams
Constants ¶
This section is empty.
Variables ¶
var ErrStartDeclined = errors.New("taskwarrior declined to start the task")
ErrStartDeclined is a start Taskwarrior declined, which has words of its own: a finished task is reopened, not declined.
Functions ¶
This section is empty.
Types ¶
type Handlers ¶
type Handlers struct {
// contains filtered or unexported fields
}
Handlers implements the Taskwarrior operations of api.StrictServerInterface, and the event stream's summary of your tasks.
func New ¶
func New(seams Seams, bound config.Taskwarrior, kit Kit) *Handlers
New builds the handlers over seams, bound with the taskwarrior settings in bound, taking the rest from the server through kit.
func (*Handlers) AddTask ¶
func (h *Handlers) AddTask(ctx context.Context, request api.AddTaskRequestObject) (api.AddTaskResponseObject, error)
AddTask adds a task from a line in Taskwarrior's grammar, refusing an empty line before Taskwarrior is asked.
func (*Handlers) AnnotateTask ¶
func (h *Handlers) AnnotateTask( ctx context.Context, request api.AnnotateTaskRequestObject, ) (api.AnnotateTaskResponseObject, error)
AnnotateTask adds a note to the task the path names, refusing one with no text before Taskwarrior is asked.
func (*Handlers) CompleteTask ¶
func (h *Handlers) CompleteTask( ctx context.Context, request api.CompleteTaskRequestObject, ) (api.CompleteTaskResponseObject, error)
CompleteTask marks the task the path names done, and answers the list after it with the task beside it as the linked tasks describe it now, since the list no longer holds it.
func (*Handlers) ListTasks ¶
func (h *Handlers) ListTasks(ctx context.Context, _ api.ListTasksRequestObject) (api.ListTasksResponseObject, error)
ListTasks answers your pending tasks, or why no Taskwarrior can be asked — an answer about where the server runs, as the review queue's is, not a missing resource.
func (*Handlers) ModifyTask ¶
func (h *Handlers) ModifyTask( ctx context.Context, request api.ModifyTaskRequestObject, ) (api.ModifyTaskResponseObject, error)
ModifyTask changes the task the path names by a line in Taskwarrior's grammar, refusing an empty line before Taskwarrior is asked.
func (*Handlers) StartTask ¶
func (h *Handlers) StartTask( ctx context.Context, request api.StartTaskRequestObject, ) (api.StartTaskResponseObject, error)
StartTask starts the task the path names.
func (*Handlers) StopTask ¶
func (h *Handlers) StopTask( ctx context.Context, request api.StopTaskRequestObject, ) (api.StopTaskResponseObject, error)
StopTask stops the task the path names.
func (*Handlers) Summary ¶
func (h *Handlers) Summary(ctx context.Context) api.TasksSummary
Summary is the stream's summary of your tasks: whether Taskwarrior can be asked, and why not; the started task; and every task linked to an issue. Until Taskwarrior has answered both reads the summary is unavailable, as the terminal draws no task mark until it has, so a page never takes a read that failed for "no task tracks this issue" and offers to track it again.
func (*Handlers) SyncTasks ¶
func (h *Handlers) SyncTasks(ctx context.Context, _ api.SyncTasksRequestObject) (api.SyncTasksResponseObject, error)
SyncTasks syncs Taskwarrior with the backend its taskrc names, and says what it printed.
func (*Handlers) TrackIssue ¶
func (h *Handlers) TrackIssue( ctx context.Context, request api.TrackIssueRequestObject, ) (api.TrackIssueResponseObject, error)
TrackIssue adds a task for an issue as the tracker has it — its key and page, the jira tag, its priority in Taskwarrior's words, and "KEY: summary" — then annotates the task with the issue's page, when there is one. The issue is read before Taskwarrior is asked anything, so an issue the tracker does not have adds no task, and neither does a key the tracker gives that is not one word: the rest would reach Taskwarrior as words of their own, ahead of the line's --.
func (*Handlers) UndoTasks ¶
func (h *Handlers) UndoTasks(ctx context.Context, _ api.UndoTasksRequestObject) (api.UndoTasksResponseObject, error)
UndoTasks reverts Taskwarrior's last change, and says how much it reverted.
type Kit ¶
type Kit struct {
// Fault maps a seam's error onto the server's problem, classified, for a
// failure no Taskwarrior words explain.
Fault func(err error) api.Problem
// Config is the taskwarrior settings in effect, which a save in Settings
// may have changed since the server started.
Config func() config.Taskwarrior
// Now is the time by the server's clock.
Now func() time.Time
// BrowseURL is the issue's page in the tracker. Nil means no tracker link
// is wired, so a task links only its own jiraurl and a track annotates
// nothing.
BrowseURL func(key jira.Key) string
// Outliving is a context with ctx's values that goes on when ctx ends and
// ends when the server stops, and the function that releases it, for the
// search for Taskwarrior every stream shares.
Outliving func(ctx context.Context) (context.Context, context.CancelFunc)
// Home is your home directory, which Taskwarrior's words can name and a
// refusal shows as ~; empty leaves them naming it.
Home string
}
Kit is what the handlers take from the server that embeds them. Fault, Config, Now and Outliving are required; BrowseURL and Home say what their absence means.
type Seams ¶
type Seams struct {
// Tasks is what the handlers ask of Taskwarrior. A nil Install, or one
// that fails, answers the task list and the snapshot's summary as not
// available — never a 404 — and a write with a nil function is refused as
// unprocessable.
Tasks seams.Tasks
// Issue reads the issue a track adds a task for. Nil means no issue
// tracker is configured, and a track is refused as unprocessable.
Issue func(ctx context.Context, issueKey jira.Key) (jira.IssueDetail, error)
}
Seams is what the handlers ask of the world.