Documentation
¶
Overview ¶
TODO: Add --name and --note flags to search command to allow searching in notes (currently only searches in item.Name)
Index ¶
- func CompileRegexp(pattern string, ignoreCase bool) (*regexp.Regexp, error)
- func HighlightMatches(text string, positions []MatchPosition) string
- func SortGroupedResults(groups []GroupedResult, order OrderBy)
- func SortResults(results []Result, order OrderBy)
- func SortTreeNodes(nodes []*TreeNode, order OrderBy)
- type GroupedResult
- type GroupingStrategy
- type MatchPosition
- type OrderBy
- type Result
- type TreeNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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
SortResults sorts a flat result list by the given order.
func SortTreeNodes ¶ added in v0.8.0
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 ¶
func FindMatches ¶
func FindMatches(text, pattern string, useRegexp, ignoreCase bool) []MatchPosition
type OrderBy ¶ added in v0.8.0
OrderBy describes a sort field and direction.
func ParseOrderBy ¶ added in v0.8.0
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 ¶
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:"-"`
}