cliapp

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 17 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func ActiveProject(dataDir string) (string, bool, error)

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

func CurrentProjectOf(t board.Task) string

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

func OpenLocalStore(dataDir string, stderr io.Writer) (*store.Store, error)

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

func ProjectTags(tags []string, flagValue, dataDir, current string) ([]string, error)

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

func Run(args []string, stdout, stderr io.Writer) int

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 SetActiveProject added in v1.8.0

func SetActiveProject(dataDir, name string) error

SetActiveProject stores name as the project local surfaces default to when no flag or KB_PROJECT names one. It is the write half of ActiveProject and writes the same state.json `kb project use` writes, atomically, so a switch made from another surface (the web UI) and `kb project current` cannot disagree.

It is exported for the same reason ActiveProject is: more than one surface resolves the active project, and a second implementation of the state file is a second chance to get its shape wrong.

func SplitProjectTags

func SplitProjectTags(tags []string) (projects, rest []string)

SplitProjectTags separates the project names a tag list carries from the tags that are not project labels, both in their original order.

func ValidateProjectName

func ValidateProjectName(name string) (string, error)

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.

Jump to

Keyboard shortcuts

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