Services.Task.List (fnord v0.9.29)

View Source

Represents a task list with an identifier, optional description, and a list of tasks. Provides core operations for creating and manipulating task lists.

Summary

Functions

Adds a task to the end of the task list.

Creates a new TaskList with the given id and optional description.

Pushes a task to the front of the task list.

Resolves tasks with the given task_id by updating their outcome and result. Only tasks in todo state are updated.

Converts the task list to a string, including the header and each task. If detail? is true, includes task results for done/failed tasks.

Types

status()

@type status() :: String.t()

t()

@type t() :: %Services.Task.List{
  description: binary() | nil,
  id: binary(),
  status: status(),
  tasks: [map()]
}

Functions

add(list, task)

@spec add(t(), map()) :: t()

Adds a task to the end of the task list.

new(id, description \\ nil)

@spec new(binary(), binary() | nil) :: t()

Creates a new TaskList with the given id and optional description.

push(list, task)

@spec push(t(), map()) :: t()

Pushes a task to the front of the task list.

resolve(list, task_id, outcome, result)

@spec resolve(t(), binary(), :done | :failed, any()) ::
  {:ok, t()} | {:error, :already_resolved | :not_found}

Resolves tasks with the given task_id by updating their outcome and result. Only tasks in todo state are updated.

to_string(list, detail? \\ false)

@spec to_string(t(), boolean()) :: binary()

Converts the task list to a string, including the header and each task. If detail? is true, includes task results for done/failed tasks.