add builders and chaining methods for various types and variables for better reusability and readability

This commit is contained in:
Robin Olsen
2026-02-19 17:26:16 +01:00
parent 2e702e799d
commit 0f41f76679
10 changed files with 179 additions and 68 deletions

View File

@@ -41,3 +41,13 @@ func (s *BeadsService) AllIssues(ctx context.Context) ([]models.Issue, error) {
return issues, nil
}
func (s *BeadsService) DeleteIssues() error {
var deleteIssues = "DELETE FROM issues;"
if _, err := s.UnderlyingDB().Exec(deleteIssues); err != nil {
return err
}
return nil
}

View File

@@ -0,0 +1,34 @@
package service
type Config struct {
RootCmd string
WebAddress string
BeadsDBPath string
IssuePrefix string
StatisticsStoragePath string
}
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
}