add config option to initialize automaticaly without prompt
This commit is contained in:
@@ -19,7 +19,6 @@ func NewBeadsService(ctx context.Context, storage beads.Storage, prefix string)
|
|||||||
if err := storage.SetConfig(ctx, "issue_prefix", prefix); err != nil {
|
if err := storage.SetConfig(ctx, "issue_prefix", prefix); err != nil {
|
||||||
return nil, fmt.Errorf("failed to set issue_prefix: %w", err)
|
return nil, fmt.Errorf("failed to set issue_prefix: %w", err)
|
||||||
}
|
}
|
||||||
fmt.Println("Initialized with prefix:", prefix)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &BeadsService{
|
return &BeadsService{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
AutoInit bool
|
||||||
RootCmd string
|
RootCmd string
|
||||||
WebAddress string
|
WebAddress string
|
||||||
BeadsDBPath string
|
BeadsDBPath string
|
||||||
@@ -9,6 +10,7 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var BaseConfig = Config{
|
var BaseConfig = Config{
|
||||||
|
AutoInit: false,
|
||||||
RootCmd: "pm",
|
RootCmd: "pm",
|
||||||
IssuePrefix: "pm",
|
IssuePrefix: "pm",
|
||||||
WebAddress: ":8080",
|
WebAddress: ":8080",
|
||||||
@@ -16,6 +18,11 @@ var BaseConfig = Config{
|
|||||||
StatisticsStoragePath: "./.pm/stats.json",
|
StatisticsStoragePath: "./.pm/stats.json",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c Config) WithAutoInit(autoInit bool) Config {
|
||||||
|
c.AutoInit = autoInit
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
func (c Config) WithRootCmd(rootCmd string) Config {
|
func (c Config) WithRootCmd(rootCmd string) Config {
|
||||||
c.RootCmd = rootCmd
|
c.RootCmd = rootCmd
|
||||||
return c
|
return c
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ import (
|
|||||||
func NewServices(ctx context.Context, config Config) (*App, func(), error) {
|
func NewServices(ctx context.Context, config Config) (*App, func(), error) {
|
||||||
var cleanupFuncs []func()
|
var cleanupFuncs []func()
|
||||||
|
|
||||||
if !initialized(config.BeadsDBPath) {
|
if !config.AutoInit {
|
||||||
fmt.Println("PM is not initialized")
|
if !initialized(config.BeadsDBPath) {
|
||||||
os.Exit(0)
|
fmt.Println("PM is not initialized")
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
store, err := beads.NewSQLiteStorage(ctx, config.BeadsDBPath)
|
store, err := beads.NewSQLiteStorage(ctx, config.BeadsDBPath)
|
||||||
|
|||||||
Reference in New Issue
Block a user