add demo with beads
This commit is contained in:
46
main.go
46
main.go
@@ -1,23 +1,51 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
"context"
|
||||||
"github.com/LazyBachelor/LazyPM/internal/storage"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||||
|
"github.com/LazyBachelor/LazyPM/internal/service"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
statStore := storage.NewJsonStorage("./.pm/test.json", &models.Statistics{
|
ctx := context.Background()
|
||||||
ID: uuid.New(),
|
|
||||||
StartTime: time.Now(),
|
|
||||||
})
|
|
||||||
|
|
||||||
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)
|
fmt.Println("Error:", err)
|
||||||
os.Exit(1)
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user