From 99bb2e39263dd477c8e438ff38ac1c158e4097a9 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 2 Mar 2026 10:58:44 +0200 Subject: store/cli: move search output to CLI layer (task 400) --- internal/store/store.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'internal/store/store.go') diff --git a/internal/store/store.go b/internal/store/store.go index 8d251b3..e1fb4e8 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -155,8 +155,16 @@ func (s *Store) processIndexFile(ctx context.Context, path, searchTerm string, r // printed; for ActionExport/ActionPathExport the content is written to ExportDir. // Actions requiring external tools (paste, open, edit) are delegated to the // optional actionFn callback — pass nil if those actions are not needed. +// The optional onMatch callback lets callers handle presentation concerns +// (for example, printing idx.String()) outside the store layer. // Returns the sorted list of matching indexes for the caller's use. -func (s *Store) Search(ctx context.Context, searchTerm string, action Action, actionFn func(context.Context, *Index, *Data) error) ([]*Index, error) { +func (s *Store) Search( + ctx context.Context, + searchTerm string, + action Action, + actionFn func(context.Context, *Index, *Data) error, + onMatch func(*Index), +) ([]*Index, error) { var indexes IndexSlice if err := s.WalkIndexes(ctx, searchTerm, func(idx *Index) error { indexes = append(indexes, idx) @@ -168,7 +176,9 @@ func (s *Store) Search(ctx context.Context, searchTerm string, action Action, ac sort.Sort(indexes) for _, idx := range indexes { - fmt.Print(idx.String()) + if onMatch != nil { + onMatch(idx) + } if err := s.applyAction(ctx, idx, action, actionFn); err != nil { return indexes, err } -- cgit v1.2.3