From 9e42ff07702cc7239bdf0a07b4910f7d8f198ca2 Mon Sep 17 00:00:00 2001 From: Robin Olsen Date: Sat, 28 Feb 2026 10:43:38 +0100 Subject: [PATCH] add config option to initialize automaticaly without prompt --- internal/service/beads.go | 1 - internal/service/config.go | 7 +++++++ internal/service/service.go | 8 +++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/service/beads.go b/internal/service/beads.go index 1a9bc66..e2b0652 100644 --- a/internal/service/beads.go +++ b/internal/service/beads.go @@ -19,7 +19,6 @@ func NewBeadsService(ctx context.Context, storage beads.Storage, prefix string) if err := storage.SetConfig(ctx, "issue_prefix", prefix); err != nil { return nil, fmt.Errorf("failed to set issue_prefix: %w", err) } - fmt.Println("Initialized with prefix:", prefix) } return &BeadsService{ diff --git a/internal/service/config.go b/internal/service/config.go index c5cc627..ff3af43 100644 --- a/internal/service/config.go +++ b/internal/service/config.go @@ -1,6 +1,7 @@ package service type Config struct { + AutoInit bool RootCmd string WebAddress string BeadsDBPath string @@ -9,6 +10,7 @@ type Config struct { } var BaseConfig = Config{ + AutoInit: false, RootCmd: "pm", IssuePrefix: "pm", WebAddress: ":8080", @@ -16,6 +18,11 @@ var BaseConfig = Config{ StatisticsStoragePath: "./.pm/stats.json", } +func (c Config) WithAutoInit(autoInit bool) Config { + c.AutoInit = autoInit + return c +} + func (c Config) WithRootCmd(rootCmd string) Config { c.RootCmd = rootCmd return c diff --git a/internal/service/service.go b/internal/service/service.go index 72d72d1..99966ae 100644 --- a/internal/service/service.go +++ b/internal/service/service.go @@ -18,9 +18,11 @@ import ( func NewServices(ctx context.Context, config Config) (*App, func(), error) { var cleanupFuncs []func() - if !initialized(config.BeadsDBPath) { - fmt.Println("PM is not initialized") - os.Exit(0) + if !config.AutoInit { + if !initialized(config.BeadsDBPath) { + fmt.Println("PM is not initialized") + os.Exit(0) + } } store, err := beads.NewSQLiteStorage(ctx, config.BeadsDBPath)