Documentation
¶
Overview ¶
Package tasksource reads and writes a project's tasks through one interface: the tracker driver, the host's issues, or a refusal naming what is missing, picked by TasksFor. It also holds what the sources return: task info, raw children and the subtask tree.
Index ¶
- Constants
- Variables
- func SubtaskNodes(rows []TreeRow, o TreeOpts) []tasktree.Node
- func TasksFor(t *target.Target) taskSource
- type FallbackSource
- func (s FallbackSource) Children(ctx context.Context, r ref.Ref) ([]RawChild, error)
- func (s FallbackSource) Comment(ctx context.Context, warnTo io.Writer, r ref.Ref, body string) (string, error)
- func (s FallbackSource) Create(ctx context.Context, warnTo io.Writer, nt NewTask) (ref.Ref, string, error)
- func (s FallbackSource) Created(ctx context.Context, r ref.Ref) (time.Time, error)
- func (s FallbackSource) Index(ctx context.Context) (string, error)
- func (s FallbackSource) Info(ctx context.Context, r ref.Ref) (TaskInfo, error)
- func (s FallbackSource) List(ctx context.Context, limit int) ([]hostops.Row, error)
- func (s FallbackSource) Read(ctx context.Context, r ref.Ref) (string, ledger.TaskRef, error)
- func (s FallbackSource) Ref(ctx context.Context, r ref.Ref) (ledger.TaskRef, error)
- func (s FallbackSource) Relink(ctx context.Context, warnTo io.Writer, r ref.Ref, parent, unwritten string) error
- func (s FallbackSource) Search(ctx context.Context, query string) ([]hostops.Row, error)
- func (s FallbackSource) SetAfter(ctx context.Context, warnTo io.Writer, r, base ref.Ref) error
- func (s FallbackSource) Title(ctx context.Context, r ref.Ref) (string, error)
- func (s FallbackSource) URL(ctx context.Context, r ref.Ref) (string, error)
- func (s FallbackSource) Update(ctx context.Context, warnTo io.Writer, r ref.Ref, p hostops.Props) error
- type HostSource
- func (s HostSource) Children(ctx context.Context, r ref.Ref) ([]RawChild, error)
- func (s HostSource) Comment(ctx context.Context, _ io.Writer, r ref.Ref, body string) (string, error)
- func (s HostSource) Create(ctx context.Context, warnTo io.Writer, nt NewTask) (ref.Ref, string, error)
- func (s HostSource) Created(ctx context.Context, r ref.Ref) (time.Time, error)
- func (s HostSource) Index(ctx context.Context) (string, error)
- func (s HostSource) Info(ctx context.Context, r ref.Ref) (TaskInfo, error)
- func (s HostSource) List(ctx context.Context, limit int) ([]hostops.Row, error)
- func (s HostSource) Read(ctx context.Context, r ref.Ref) (string, ledger.TaskRef, error)
- func (s HostSource) Ref(ctx context.Context, r ref.Ref) (ledger.TaskRef, error)
- func (s HostSource) Relink(ctx context.Context, _ io.Writer, r ref.Ref, parent, unwritten string) error
- func (s HostSource) Search(ctx context.Context, query string) ([]hostops.Row, error)
- func (s HostSource) SetAfter(ctx context.Context, _ io.Writer, r, base ref.Ref) error
- func (s HostSource) Title(ctx context.Context, r ref.Ref) (string, error)
- func (s HostSource) URL(ctx context.Context, r ref.Ref) (string, error)
- func (s HostSource) Update(ctx context.Context, _ io.Writer, r ref.Ref, p hostops.Props) error
- type NewTask
- type RawChild
- type RefusedSource
- func (s RefusedSource) Children(context.Context, ref.Ref) ([]RawChild, error)
- func (s RefusedSource) Comment(context.Context, io.Writer, ref.Ref, string) (string, error)
- func (s RefusedSource) Create(context.Context, io.Writer, NewTask) (ref.Ref, string, error)
- func (s RefusedSource) Created(context.Context, ref.Ref) (time.Time, error)
- func (s RefusedSource) Index(context.Context) (string, error)
- func (s RefusedSource) Info(context.Context, ref.Ref) (TaskInfo, error)
- func (s RefusedSource) List(context.Context, int) ([]hostops.Row, error)
- func (s RefusedSource) Read(context.Context, ref.Ref) (string, ledger.TaskRef, error)
- func (s RefusedSource) Ref(context.Context, ref.Ref) (ledger.TaskRef, error)
- func (s RefusedSource) Refuse(verb string) error
- func (s RefusedSource) RefuseCreate() error
- func (s RefusedSource) RefuseWrite(verb, unwritten string) error
- func (s RefusedSource) Relink(_ context.Context, _ io.Writer, _ ref.Ref, _, unwritten string) error
- func (s RefusedSource) Search(context.Context, string) ([]hostops.Row, error)
- func (s RefusedSource) SetAfter(context.Context, io.Writer, ref.Ref, ref.Ref) error
- func (s RefusedSource) Title(context.Context, ref.Ref) (string, error)
- func (s RefusedSource) URL(context.Context, ref.Ref) (string, error)
- func (s RefusedSource) Update(context.Context, io.Writer, ref.Ref, hostops.Props) error
- type TaskInfo
- type TreeOpts
- type TreeRow
Constants ¶
const MayExist = "the task may exist already: check the tracker before running create again"
MayExist follows every failed create but a driver's exit 4: the driver may have made the task before failing, so running create again could make it twice.
const MayPosted = "the comment may have been posted: check the task before running comment again"
MayPosted follows every failed comment: the tracker may have taken it before failing, so posting again could post it twice.
const UnwrittenNothing = "nothing was written"
UnwrittenNothing is a write's refusal when no write came before it.
Variables ¶
var ErrNoParentLink = errors.New("the tracker has no parent link")
var VerbNeeds = map[string]string{ trackerdriver.VerbRead: "`f10 task read`, `f10 start` needs", trackerdriver.VerbBranch: "`f10 start` needs for a branch name past the bare id", trackerdriver.VerbURL: "`f10 task open <id>` needs", trackerdriver.VerbIndex: "`f10 task open` with no id needs", trackerdriver.VerbList: "`f10 task open --print` and the board's next rows need", trackerdriver.VerbSearch: "`f10 task search` needs", }
VerbNeeds names what needs each verb, for the refusal when a driver declines it.
Functions ¶
func SubtaskNodes ¶
SubtaskNodes is the one way task rows become tree nodes.
Types ¶
type FallbackSource ¶
type FallbackSource struct {
Rest taskSource
// contains filtered or unexported fields
}
FallbackSource asks the driver, and the rest only for a verb it declines.
type HostSource ¶
type HostSource struct {
// contains filtered or unexported fields
}
HostSource is the host's issues as the tracker.
func (HostSource) Info ¶
Info reads the item whatever it is, since start refuses a PR by its own words rather than by the issue read's.
type NewTask ¶
NewTask is task create's input, read and resolved once whichever source takes it; parent and after are zero when not given.
type RawChild ¶
type RawChild struct {
ID string `json:"id"`
Title string `json:"title"`
URL string `json:"url"`
State string `json:"state"`
Labels []string `json:"labels"`
After string `json:"after"`
Body string `json:"body"`
// Stated: State is the tracker's own, as Info reports it. Only the host's
// issues set it. A driver's rows never claim it, whatever their state.
Stated bool `json:"-"`
}
type RefusedSource ¶
type RefusedSource struct {
Target *target.Target
Driver *trackerdriver.Driver // the driver that declined, nil when none was found
// contains filtered or unexported fields
}
RefusedSource is a tracker f10 cannot reach: not the host's issues and no driver taking the verb, or the host's issues with no host CLI. Reads fail plainly. Writes exit 3 so capture falls back to its adapters, except that comment and update with no host CLI fail plainly (RefuseWrite).
func (RefusedSource) Children ¶
Children: a driver declining it on a tracker that is not the host's issues leaves no parent link to read, which status, drive and finish expect.
func (RefusedSource) Created ¶
Created is undated for a tracker that is not the host's issues; the host's issues with no CLI fail, since that tracker does carry a date.
func (RefusedSource) Refuse ¶
func (s RefusedSource) Refuse(verb string) error
func (RefusedSource) RefuseCreate ¶
func (s RefusedSource) RefuseCreate() error
RefuseCreate is exit 3 in every case, so capture creates the task through its own adapter.
func (RefusedSource) RefuseWrite ¶
func (s RefusedSource) RefuseWrite(verb, unwritten string) error
RefuseWrite keeps a missing host CLI a plain error: the checkout is misconfigured, not a tracker capture should route around.
type TaskInfo ¶
type TaskInfo struct {
Body string
Closed bool
Stated bool // Closed comes from the tracker: a driver reports no state
Pull bool // the number is a pull request: GitHub numbers issues and PRs alike
Labels []string // the host's labels; a driver reports none
}
A TaskInfo is what the tracker says about a task beyond its branch.
type TreeOpts ¶
type TreeOpts struct {
// Head is a parent node above the rows, which hang one level under it
Head *TreeRow
// TitleBelow puts the title on the line under the row, not in a cell
TitleBelow bool
// URL adds a `↗ <url>` line under the row, in the title's column
URL bool
// Id replaces row i's id cell; nil prints the id as is
ID func(i int) tasktree.Cell
// Extra is row i's cells after the title and url, and the notes under it
Extra func(i int) ([]tasktree.Cell, []tasktree.Note)
}
TreeOpts is how a subtask tree's rows become nodes.