Documentation
¶
Overview ¶
Package hostops is how commands reach the host and the tracker: the host CLI with the title template, the task sources behind one interface, task rows and the After: line.
Index ¶
- Constants
- Variables
- func AfterID(line string) string
- func AfterIn(body string) string
- func OneIDHeading(doc string, r ref.Ref, titles tasktitle.Template) string
- func RetitleAfter(ctx context.Context, warnTo io.Writer, t *target.Target, r ref.Ref, ...)
- func RowRefs(rows []Row) []ledger.TaskRef
- func StaleAt(created time.Time, staleAfter facts.StaleAfter, now time.Time) bool
- func SubtaskNodes(rows []TreeRow, o TreeOpts) []tasktree.Node
- func TaskTitle(doc string) string
- func TasksFor(t *target.Target) taskSource
- func WriteRows(w io.Writer, rows []Row, none string) error
- 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) ([]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) ([]Row, 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 Props) error
- type Host
- func (h Host) In(dir string) Host
- func (h Host) IssueCreated(ctx context.Context, number string) (time.Time, error)
- func (h Host) IssueDoc(ctx context.Context, id, number string, staleAfter facts.StaleAfter) (string, forge.Issue, error)
- func (h Host) IssueTitle(ctx context.Context, number string) (string, error)
- func (h Host) IssueURL(ctx context.Context, number string) (string, error)
- func (h Host) ListIssues(ctx context.Context, query, prefix string, priorities map[string]string, ...) ([]Row, error)
- func (h Host) MergeMethod(ctx context.Context, declared string) (string, string, error)
- func (h Host) OpenPull(ctx context.Context, n forge.NewPull) (string, error)
- func (h Host) PRURL(ctx context.Context, number string) (string, error)
- func (h Host) PickupOf(number string, p forge.PR) *Pickup
- func (h Host) PullRows(ctx context.Context) ([]Row, error)
- func (h Host) Relink(ctx context.Context, parent, child string) error
- func (h Host) SetTitle(ctx context.Context, number, title string) error
- func (h Host) TitleChanges(ctx context.Context, number string) ([]titleChange, error)
- func (h Host) Update(ctx context.Context, number string, p Props, priorities map[string]string) 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) ([]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) ([]Row, 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 Props) error
- type NewTask
- type Pickup
- type Props
- 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) ([]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) ([]Row, 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, Props) error
- type Row
- type TaskInfo
- type TreeOpts
- type TreeRow
Constants ¶
const IssuePage = 30
IssuePage is the first page `task open --print` and `task search` show.
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{ driver.VerbRead: "`f10 task read`, `f10 start` and `f10 drive` need", driver.VerbBranch: "`f10 start` and `f10 drive` need for a branch name past the bare id", driver.VerbURL: "`f10 task open <id>` needs", driver.VerbIndex: "`f10 task open` with no id needs", driver.VerbList: "`f10 task open --print` and the board's next rows need", driver.VerbSearch: "`f10 task search` needs", }
VerbNeeds names what needs each verb, for the refusal when a driver declines it.
Functions ¶
func AfterIn ¶
AfterIn is the id the body's After: line names, or "": bare or as a link to the task, with emphasis or code marks around either part ignored.
func OneIDHeading ¶
OneIDHeading collapses `# <id>: <id>: <title>`, the id a driver adds over the one tracker.title wrote, to one id.
func RetitleAfter ¶
RetitleAfter writes tracker.title onto an issue just written, since the template needs the number and a driver has no title verb; the write stands, so a failure is a warning.
func StaleAt ¶
StaleAt is task read's stale mark and task stale's age check in one place, so the two never disagree; an undeclared or bad stale_after is never stale.
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 Host ¶
type Host struct {
forge.Host
Titles tasktitle.Template // tracker.title; zero leaves titles as the host holds them
Prefix string // the task id prefix titles are rendered and stripped with
}
A Host is the forge binding with the nouns only this command acts on; the reads standup and the board share live on forge.Host itself.
func HostOf ¶
HostOf is the CLI the probe settled on; a wrong guess opens the wrong site, so "unknown" refuses rather than picking.
func OptionalHostOf ¶
OptionalHostOf is the host, or nil for a checkout with no host CLI: a reader that works without one skips it rather than failing.
func (Host) IssueCreated ¶
IssueCreated is the issue's created date, zero when the host gives none.
func (Host) IssueTitle ¶
IssueTitle is the one field the default branch name carries.
func (Host) ListIssues ¶
func (Host) MergeMethod ¶
MergeMethod is the declared method, else the one the repo allows; a GitHub repo allowing several gets squash with a note, since a history-rewriting default is not silent.
func (Host) OpenPull ¶
OpenPull opens the request and reads the url back from the host, since neither CLI prints it in a form worth parsing.
func (Host) PickupOf ¶
PickupOf reads the request through f10 pr, which reads one in any state on either host, so the prompt is the same text on GitHub and GitLab.
func (Host) Relink ¶
Relink puts child under parent, or with parent "" takes it out from under the parent it has.
func (Host) TitleChanges ¶
func (Host) Update ¶
func (h Host) Update(ctx context.Context, number string, p Props, priorities map[string]string) error
Update: an issue has two states and no custom properties, so `--status` takes open or closed and `--set` is refused; the labels of every other priority level come off, so the issue carries one; an assignee replaces the issue's, as glab's flag does; a title renamed by hand gets its prefix back.
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 Pickup ¶
type Pickup struct {
Number string
URL string
Branch string // the request's head, as the host names it
View string // the f10 command that reads the request with its comments
Diff string
// Sha is where a merged or closed request is checked out, "" for an open
// one; state says which it is, for the prompt and the report; headRef is
// the host's ref for a closed request's head, which no branch holds
SHA string
State string
HeadRef string
}
type RefusedSource ¶
type RefusedSource struct {
Target *target.Target
Driver *driver.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 Row ¶
type Row struct {
ID string `json:"id"`
Title string `json:"title"`
Status string `json:"status,omitempty"`
URL string `json:"url,omitempty"`
Priority string `json:"priority,omitempty"`
After string `json:"after,omitempty"` // the base its body's After: line names, where the source gives one
Body string `json:"body,omitempty"` // read for its After: line; never printed
Assignee string `json:"assignee,omitempty"` // the tracker's assignee, where the source gives one
Created time.Time `json:"created,omitzero"`
}
A Row holds the fields f10 relies on; a driver may carry more, which f10 neither requires nor reads.
func SettlePriorities ¶
SettlePriorities warns once per distinct unknown value: a driver emitting its tracker's own word does so on every row of the page.
type TaskInfo ¶
type TaskInfo struct {
Body string
Closed bool
Pull bool // the number is a pull request: GitHub numbers issues and PRs alike
}
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>` cell after the title
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.