driver

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package driver runs a project's tracker driver: an executable at .f10/driver satisfying the verb contract in docs/driver-contract.md.

f10 specifies that contract and implements none of it. What a driver talks to - Notion, Jira, a wiki, a spreadsheet - is the project's business, and so is the language it is written in. The one thing f10 fixes is the shape of the conversation: a verb, an argument, data on stdout, and a reserved exit code for a verb the driver does not offer.

Read verbs return data and change nothing; write verbs change the tracker and only the tracker. Neither acts on the local machine: f10 opens every url and creates every branch, which is what lets `open` mean the same thing for a task as for a pull request, where no driver is involved.

Index

Constants

View Source
const (
	VerbRead     = "read"     // stdout: the task as markdown
	VerbURL      = "url"      // stdout: one url
	VerbSearch   = "search"   // stdout: JSON rows, one task each
	VerbBranch   = "branch"   // stdout: one branch name, never created
	VerbChildren = "children" // stdout: JSON rows, one subtask each
	VerbIndex    = "index"    // stdout: one url, the task list; no argument
	VerbList     = "list"     // stdout: JSON rows, the first page of open tasks; no argument

	// VerbCreate is the first write verb: stdin is the task as markdown,
	// `# <title>` first; stdout is the new task's id.
	VerbCreate = "create"

	// VerbComment adds a comment to a task: stdin is the comment as
	// markdown; stdout is the comment's url, or nothing.
	VerbComment = "comment"

	// VerbUpdate sets a task's properties from flags, each an absolute
	// value; stdin is empty and stdout ignored.
	VerbUpdate = "update"
)

Verbs a driver may implement. All but create, comment and update are read verbs.

View Source
const ExitUnsupported = 3

ExitUnsupported is the contract's reserved exit code: the driver ran and understood the call, but does not implement that verb. It is a normal answer, not a failure, so a driver can offer `read` without `search`.

Variables

View Source
var ErrUnsupported = errors.New("driver does not implement this verb")

ErrUnsupported reports the reserved exit code back to the caller, which then falls back or explains, rather than failing the command.

View Source
var Priorities = []string{"urgent", "high", "medium", "low"}

Priorities is the contract's ordered priority vocabulary, most urgent first. A search or list row may carry one as its `priority`; a driver maps its tracker's own values onto these, and a row without one has no priority.

Functions

func PriorityRank added in v0.38.0

func PriorityRank(value string) (int, bool)

PriorityRank places a row's priority value in Priorities, case and surrounding space ignored: its index and true, or -1 and false for a value outside the vocabulary.

Types

type Driver

type Driver struct {
	Path string // the executable
	Dir  string // the checkout it runs in
}

A Driver is one project's executable.

func Find

func Find(storageRoot, dir string) *Driver

Find returns the driver for a storage root, or nil when the project has none - the ordinary case, which callers answer by falling back to the host's issues.

func (*Driver) Run

func (d *Driver) Run(ctx context.Context, verb string, args ...string) (string, error)

Run invokes one verb and returns its stdout. The reserved code becomes ErrUnsupported; any other non-zero exit is a failure carrying the driver's own stderr verbatim, because the driver knows why it failed and f10 does not.

func (*Driver) RunInput added in v0.41.0

func (d *Driver) RunInput(ctx context.Context, input, verb string, args ...string) (string, string, error)

RunInput invokes a write verb with input on its stdin and returns its stdout and, on success, its stderr: a warning about a property the tracker has no field for. It is never retried, because a failed write may still have changed the tracker.

Jump to

Keyboard shortcuts

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