diff options
Diffstat (limited to 'internal/ipc/ipc.go')
| -rw-r--r-- | internal/ipc/ipc.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/internal/ipc/ipc.go b/internal/ipc/ipc.go index b1a997a..691dadf 100644 --- a/internal/ipc/ipc.go +++ b/internal/ipc/ipc.go @@ -20,6 +20,11 @@ type Request struct { BeforeID int64 `json:"before_id,omitempty"` ID int64 `json:"id,omitempty"` + // For "list": a non-empty Query switches from most-recent-first to + // an FTS5 search (see store.Store.Search for syntax), ranked by + // relevance. + Query string `json:"query,omitempty"` + // For "repeat": send Raw to scheme://host exactly as given. Scheme string `json:"scheme,omitempty"` Host string `json:"host,omitempty"` @@ -69,7 +74,17 @@ func (c *Client) Close() error { // List returns up to limit history summaries older than beforeID (0 for // the most recent), newest first. func (c *Client) List(limit int, beforeID int64) ([]store.Summary, error) { - if err := c.enc.Encode(Request{Type: "list", Limit: limit, BeforeID: beforeID}); err != nil { + return c.list(Request{Type: "list", Limit: limit, BeforeID: beforeID}) +} + +// Search returns up to limit history summaries matching an FTS5 query +// (see store.Store.Search for syntax), ranked by relevance. +func (c *Client) Search(query string, limit int, beforeID int64) ([]store.Summary, error) { + return c.list(Request{Type: "list", Query: query, Limit: limit, BeforeID: beforeID}) +} + +func (c *Client) list(req Request) ([]store.Summary, error) { + if err := c.enc.Encode(req); err != nil { return nil, err } var resp Response |