Documentation
¶
Overview ¶
Package taskfilter parses the structured token grammar shared by every surface that filters tasks: the TUI filter bar, saved views, `ty list --view`, and the HTTP API.
The grammar is deliberately small and greppable:
status:blocked is:blocked only blocked tasks status:in-progress is:in-progress queued + processing status:open is:open anything not done/archived is:pinned is:unpinned pin state is:workflow is:task workflow steps vs standalone tasks has:pr no:pr tasks with/without a pull request tag:release tasks carrying a comma-separated tag [project] project tag (OR'd across tags) @mona the machine a task ran on (OR'd)
Repeating a status token ORs the statuses together, so "status:in-progress status:blocked" is "the things I'm working on right now" — the view the list mode was built for.
Everything the grammar does not recognise is left alone and handed back as the free-text remainder, so callers keep whatever keyword matching they already do (the TUI fuzzy-scores it; the CLI does a substring match).
Index ¶
- Constants
- func StatusTokens() []string
- type Query
- func (q Query) Filter(tasks []*db.Task) []*db.Task
- func (q Query) HasStructured() bool
- func (q Query) IsZero() bool
- func (q Query) Match(t *db.Task) bool
- func (q Query) MatchAll(t *db.Task) bool
- func (q Query) MatchKeyword(t *db.Task) bool
- func (q Query) MatchProject(t *db.Task) bool
- func (q Query) ResolveProjects(resolve func(string) string) Query
- func (q Query) Rest() string
- func (q Query) WithLocalHost(name string) Query
Constants ¶
const ( KindWorkflow = "workflow" KindTask = "task" )
Kind values for the is:workflow / is:task token.
Variables ¶
This section is empty.
Functions ¶
func StatusTokens ¶
func StatusTokens() []string
StatusTokens returns the accepted status:/is: status names in a stable order, for help text and shell completion.
Types ¶
type Query ¶
type Query struct {
// Statuses is the set of task statuses to keep. Empty means "any status".
Statuses []string
// Kind is KindWorkflow, KindTask, or "" for both.
Kind string
// Pinned, when set, requires the task's pin state to match.
Pinned *bool
// HasPR, when set, requires the task to have (or not have) a pull request.
HasPR *bool
// Tags are tag names the task must carry — all of them, so repeating
// tag: narrows rather than widens (unlike status:, which ORs).
Tags []string
// Projects are the [project] tags to keep, OR'd together. Names are
// lowercased; resolve aliases before matching (see ResolveProjects).
Projects []string
// PartialProject is a trailing unclosed "[proj" the user is still typing.
// Only the TUI's autocomplete cares; Match ignores it.
PartialProject string
// Hosts are the `@host` tokens — the machine a task ran on — OR'd together.
// A bare "@" is the empty string and means "ran on some other machine".
Hosts []string
// LocalHost is this machine's short name, which is what lets `@mona` mean
// the same thing on mona as anywhere else: a task that ran here carries no
// placement target at all, so without it the local machine would be the one
// host in the fleet you could not name. Set it with WithLocalHost.
LocalHost string
// Keyword is the free text left after every recognised token was removed.
Keyword string
}
Query holds the structured predicates parsed out of a filter string. The zero value matches every task, so callers can apply it unconditionally.
func Parse ¶
Parse extracts every structured token from raw and returns the resulting Query. Unrecognised text — including [project] tags, which are parsed into Projects — ends up in Keyword.
Tokens are matched case-insensitively; the keyword remainder keeps its original case so callers can decide how to fold it.
func (Query) HasStructured ¶
HasStructured reports whether any non-keyword predicate is set. The TUI uses this to decide whether the structured pass can change the result at all.
func (Query) IsZero ¶
IsZero reports whether the query constrains nothing at all — no structured predicate, no project, no keyword. Callers use it to skip filtering entirely.
func (Query) Match ¶
Match reports whether a task satisfies the structured predicates. It deliberately ignores Projects and Keyword: those are matched (and, in the TUI, fuzzy-ranked) by the caller, which owns alias resolution and scoring.
func (Query) MatchAll ¶
MatchAll applies every predicate — structured, project, and keyword. This is the whole meaning of a saved view outside the TUI.
func (Query) MatchKeyword ¶
MatchKeyword reports whether a task matches the free-text remainder by plain substring, across the fields a person would search: id, title, body, summary and project. The TUI replaces this with fuzzy ranking; the CLI and API use it as-is so a saved view means the same thing everywhere.
func (Query) MatchProject ¶
MatchProject reports whether a task's project satisfies the [project] tags. Names are compared case-insensitively; pass already-resolved project names (see ResolveProjects) so aliases like "ol" work.
func (Query) ResolveProjects ¶
ResolveProjects rewrites project tags through resolve, which maps a name or alias to the canonical project name. A resolver that returns "" leaves the name untouched, so an unknown project still filters (to nothing) rather than silently widening the view to everything.
func (Query) Rest ¶
Rest returns the query with every structured token removed: the [project] tags followed by the free-text keyword, followed by any half-typed tag.
It exists so a caller with its own matcher for the unstructured part — the TUI, which fuzzy-ranks rather than substring-matches — can hand that matcher exactly the text it understands, without having to know which tokens this package consumed. The partial tag is emitted last because an unclosed "[" swallows the remainder of the string by definition.
func (Query) WithLocalHost ¶
WithLocalHost names this machine for `@host` matching.