Files
LazyPM/internal/models/config.go
Robin Olsen e4b6074303 fix typo
make sure we check env is set
2026-03-10 13:34:13 +01:00

72 lines
1.4 KiB
Go

package models
import "os"
type Config struct {
DbUri string
AutoInit bool
RootCmd string
WebAddress string
BeadsDBPath string
IssuePrefix string
StatisticsStoragePath string
ActionLogger func(string)
}
var BaseConfig = Config{
DbUri: "",
AutoInit: false,
RootCmd: "pm",
IssuePrefix: "pm",
WebAddress: ":8080",
BeadsDBPath: "./.pm/db.db",
StatisticsStoragePath: "./.pm/stats.json",
}
func (c Config) LoadFromEnv() Config {
if dbURI, ok := os.LookupEnv("DB_URI"); ok {
c.DbUri = dbURI
}
return c
}
func (c Config) WithDbUri(uri string) Config {
c.DbUri = uri
return c
}
func (c Config) WithAutoInit(autoInit bool) Config {
c.AutoInit = autoInit
return c
}
func (c Config) WithRootCmd(rootCmd string) Config {
c.RootCmd = rootCmd
return c
}
func (c Config) WithWebAddress(webAddress string) Config {
c.WebAddress = webAddress
return c
}
func (c Config) WithBeadsDBPath(beadsDBPath string) Config {
c.BeadsDBPath = beadsDBPath
return c
}
func (c Config) WithIssuePrefix(issuePrefix string) Config {
c.IssuePrefix = issuePrefix
return c
}
func (c Config) WithStatisticsStoragePath(path string) Config {
c.StatisticsStoragePath = path
return c
}
func (c Config) WithActionLogger(logger func(string)) Config {
c.ActionLogger = logger
return c
}