Added a store
All checks were successful
Build / build (push) Successful in 1m0s

This commit is contained in:
Leon Mika 2026-01-26 09:31:14 +11:00
parent 1d0d3230c9
commit f96b8a8266
9 changed files with 154 additions and 7 deletions

13
app.go
View file

@ -15,13 +15,14 @@ import (
// App struct
type App struct {
store *Store
uclInst *ucl.Inst
ctx context.Context
}
// NewApp creates a new App application struct
func NewApp() *App {
func NewApp(store *Store) *App {
uclInst := ucl.New(
ucl.WithModule(builtins.CSV(nil)),
ucl.WithModule(builtins.Fns()),
@ -34,6 +35,7 @@ func NewApp() *App {
ucl.WithModule(builtins.Time()),
)
return &App{
store: store,
uclInst: uclInst,
}
}
@ -44,6 +46,15 @@ func (a *App) startup(ctx context.Context) {
a.ctx = context.WithValue(ctx, uclInstKey, a.uclInst)
}
func (a *App) LoadCurrentBuffer() (string, error) {
return a.store.LoadBuffer()
}
func (a *App) SaveCurrentBuffer(buffer string) error {
log.Printf("Saving buffer")
return a.store.SaveBuffer(buffer)
}
func (a *App) ListProcessors() (resp []ListProcessorsResponse) {
for k, v := range TextFilters {
resp = append(resp, ListProcessorsResponse{Name: k, Label: v.Label})