search

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

TODO: Add --name and --note flags to search command to allow searching in notes (currently only searches in item.Name)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileRegexp

func CompileRegexp(pattern string, ignoreCase bool) (*regexp.Regexp, error)

func HighlightMatches

func HighlightMatches(text string, positions []MatchPosition) string

func SortGroupedResults added in v0.8.0

func SortGroupedResults(groups []GroupedResult, order OrderBy)

SortGroupedResults sorts groups. For parent/path/match it sorts by label; for modified/created it sorts by the max (or min) timestamp among children.

func SortResults added in v0.8.0

func SortResults(results []Result, order OrderBy)

SortResults sorts a flat result list by the given order.

func SortTreeNodes added in v0.8.0

func SortTreeNodes(nodes []*TreeNode, order OrderBy)

Types

type GroupedResult added in v0.8.0

type GroupedResult struct {
	GroupKey   string   `json:"group_key"`
	GroupLabel string   `json:"group_label"`
	Children   []Result `json:"children"`
}

GroupedResult represents search results grouped by a generic key.

func SearchItemsGroupedBy added in v0.8.0

func SearchItemsGroupedBy(items []*workflowy.Item, pattern string, useRegexp, ignoreCase, includeCompleted bool, strategy GroupingStrategy) []GroupedResult

SearchItemsGroupedBy searches items and groups results using the given strategy.

func (GroupedResult) String added in v0.8.0

func (g GroupedResult) String() string

type GroupingStrategy added in v0.8.0

type GroupingStrategy interface {
	GroupKey(item *workflowy.Item, ancestors []*workflowy.Item) string
	GroupLabel(item *workflowy.Item, ancestors []*workflowy.Item) string
}

GroupingStrategy determines how search results are grouped.

func ParseGroupBy added in v0.8.0

func ParseGroupBy(value string, pathMaxLen int) (GroupingStrategy, error)

ParseGroupBy parses a --group-by value into a GroupingStrategy.

type MatchPosition

type MatchPosition struct {
	Start int `json:"start"`
	End   int `json:"end"`
}

func FindMatches

func FindMatches(text, pattern string, useRegexp, ignoreCase bool) []MatchPosition

type OrderBy added in v0.8.0

type OrderBy struct {
	Field     string
	Ascending bool
}

OrderBy describes a sort field and direction.

func ParseOrderBy added in v0.8.0

func ParseOrderBy(value string) (OrderBy, error)

ParseOrderBy parses a --order-by value like "+modified", "-created", "match".

type Result

type Result struct {
	ID              string          `json:"id"`
	Name            string          `json:"name"`
	HighlightedName string          `json:"highlighted_name"`
	URL             string          `json:"url"`
	MatchPositions  []MatchPosition `json:"match_positions"`

	CreatedAt  int64  `json:"-"`
	ModifiedAt int64  `json:"-"`
	ParentName string `json:"-"`
	Path       string `json:"-"`
}

func SearchItems

func SearchItems(items []*workflowy.Item, pattern string, useRegexp, ignoreCase, includeCompleted bool) []Result

func (Result) String

func (r Result) String() string

type TreeNode added in v0.8.0

type TreeNode struct {
	ID       string      `json:"id"`
	Name     string      `json:"name"`
	URL      string      `json:"url"`
	IsMatch  bool        `json:"is_match,omitempty"`
	Children []*TreeNode `json:"children,omitempty"`

	HighlightedName string          `json:"highlighted_name,omitempty"`
	MatchPositions  []MatchPosition `json:"match_positions,omitempty"`

	CreatedAt  int64 `json:"-"`
	ModifiedAt int64 `json:"-"`
}

func SearchItemsTree added in v0.8.0

func SearchItemsTree(items []*workflowy.Item, pattern string, useRegexp, ignoreCase, includeCompleted bool) []*TreeNode

func (*TreeNode) String added in v0.8.0

func (n *TreeNode) String() string

Jump to

Keyboard shortcuts

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