Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Hadi
2026-05-12 19:12:29 +02:00
commit e8e64eff12
101 changed files with 10081 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
package history
import (
tea "charm.land/bubbletea/v2"
"github.com/anotherhadi/spilltea/internal/db"
)
type searchKind int
const (
searchKindOff searchKind = iota
searchKindFulltext
searchKindSQL
)
type SearchResultMsg struct {
Entries []db.Entry
}
type SearchErrMsg struct {
Err error
}
func SearchCmd(database *db.DB, term string) tea.Cmd {
return func() tea.Msg {
if database == nil {
return SearchResultMsg{}
}
entries, err := database.SearchEntries(term)
if err != nil {
return SearchErrMsg{Err: err}
}
return SearchResultMsg{Entries: entries}
}
}
func SQLCmd(database *db.DB, query string) tea.Cmd {
return func() tea.Msg {
if database == nil {
return SearchResultMsg{}
}
entries, err := database.QueryEntries(query)
if err != nil {
return SearchErrMsg{Err: err}
}
return SearchResultMsg{Entries: entries}
}
}