From 1bd50217a1d32fc2ff0967cb1db2da7624c6f976 Mon Sep 17 00:00:00 2001 From: Robin Olsen Date: Mon, 2 Feb 2026 11:35:05 +0100 Subject: [PATCH] add demo with beads --- main.go | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index 1ca39d7..50d8948 100644 --- a/main.go +++ b/main.go @@ -1,23 +1,51 @@ package main import ( - "github.com/LazyBachelor/LazyPM/internal/models" - "github.com/LazyBachelor/LazyPM/internal/storage" + "context" "fmt" "os" - "time" - "github.com/google/uuid" + "github.com/LazyBachelor/LazyPM/internal/models" + "github.com/LazyBachelor/LazyPM/internal/service" ) func main() { - statStore := storage.NewJsonStorage("./.pm/test.json", &models.Statistics{ - ID: uuid.New(), - StartTime: time.Now(), - }) + ctx := context.Background() - if err := statStore.Init(); err != nil { + config := service.Config{ + IssuePrefix: "pm", + BeadsDBPath: "./.pm/db.db", + StatisticsStoragePath: "./.pm/stats.json", + } + svc, cancel, err := service.NewServices(ctx, config) + if err != nil { fmt.Println("Error:", err) os.Exit(1) } + defer cancel() + + issue := &models.Issue{ + IssueType: models.TypeTask, + Title: "Sample Issue", + Description: "This is a sample issue created for testing.", + Status: models.StatusOpen, + } + + err = svc.Beads.CreateIssue(ctx, issue, "") + if err != nil { + fmt.Println("Error:", err) + os.Exit(1) + } + + fetchedIssues, err := svc.Beads.SearchIssues(ctx, "", models.IssueFilter{}) + + if err != nil { + fmt.Println("Error:", err) + os.Exit(1) + } + + for _, iss := range fetchedIssues { + fmt.Printf("Issue ID: %s, Title: %s, Status: %s\n", iss.ID, iss.Title, iss.Status) + } + }