Documentation
¶
Overview ¶
Package cliapp implements the kb command-line interface against the local SQLite store. Task ids are stable per-board sequence numbers ("#12", bare "12" works too) with UUIDs still addressable by unique prefix.
Index ¶
- Variables
- func ActiveProject(dataDir string) (string, bool, error)
- func BackfillProjects(st ProjectBackfiller, user string) (int, error)
- func CurrentProjectOf(t board.Task) string
- func OpenLocalStore(dataDir string, stderr io.Writer) (*store.Store, error)
- func ProjectTags(tags []string, flagValue, dataDir, current string) ([]string, error)
- func Run(args []string, stdout, stderr io.Writer) int
- func SplitProjectTags(tags []string) (projects, rest []string)
- func ValidateProjectName(name string) (string, error)
- type ProjectBackfiller
Constants ¶
This section is empty.
Variables ¶
var ErrNoProject = errors.New(`no project set: run "kb project use <name>" to pick one, or pass -p <name> (KB_PROJECT also works)`)
ErrNoProject is the refusal every mandatory-project path shares. It names both fixes because the command that hits it is the one being written.
Functions ¶
func ActiveProject ¶
ActiveProject resolves the project local surfaces default to when no flag names one: KB_PROJECT, else the project stored by kb project use. The TUI takes its opening scope and its editor default from it, which is why the resolution is exported rather than copied.
func BackfillProjects ¶
func BackfillProjects(st ProjectBackfiller, user string) (int, error)
BackfillProjects gives every task without exactly one project:: label the invariant it is missing: none becomes project::inbox, several collapse to the first. It is idempotent — a second pass finds nothing to do — and returns the number of tasks it rewrote.
It runs automatically whenever a local store is opened rather than behind an explicit command: the mandatory-project rule is only true if it holds for the tasks that predate it, and OpenLocalStore is the one startup path every local surface already shares (it is where the legacy markdown import lives too). Nothing is written once the board is clean.
func CurrentProjectOf ¶
CurrentProjectOf returns the single project a task carries, or "" when it carries none or more than one (both of which the caller then replaces).
func OpenLocalStore ¶
OpenLocalStore opens the local SQLite store with the same data-directory, secret, and legacy-import behavior used by the task CLI. Other local human interfaces use this rather than quietly inventing a second startup path.
func ProjectTags ¶
ProjectTags returns tags carrying exactly one project:: label — the invariant every task-mutating path funnels through, on every surface. The CLI passes its -p value as flagValue; surfaces with their own project argument (the MCP tools) pass that, and surfaces with none (the TUI overlays) pass "" and take the active project.
A project:: label spelled directly in --tag is as explicit as -p, so it beats KB_PROJECT and the stored active project; contradicting an explicit -p is an error rather than a silent winner. current is the project the task already has ("" when it has none or when the task is new): editing labels on an existing task keeps it in its project instead of dragging it into whatever happens to be active.
func Run ¶
Run executes one kb CLI invocation. args starts with the subcommand, e.g. ["add", "Fix bug", "--prio", "2"]. It returns the process exit code: 0 on success, 1 on runtime errors, 2 on usage errors.
func SplitProjectTags ¶
SplitProjectTags separates the project names a tag list carries from the tags that are not project labels, both in their original order.
func ValidateProjectName ¶
ValidateProjectName checks a project name by the rule already applied to label values: non-empty, no whitespace, no leading '#'. It additionally rejects "::" so a name can never smuggle a second scope into the label.
Types ¶
type ProjectBackfiller ¶
type ProjectBackfiller interface {
FilterTasks(user string, f store.TaskFilter) ([]board.Task, error)
UpdateTask(user, ref string, p store.TaskPatch) (board.Task, error)
}
ProjectBackfiller is the slice of the store the backfill needs: *store.Store satisfies it, and a stub can make either half fail.