This commit is contained in:
2025-04-13 20:22:32 +03:00
parent b8cb7af3bb
commit e3aaa88822
8 changed files with 139 additions and 109 deletions

View File

@ -53,6 +53,14 @@ func New(ctx context.Context) *AppBuilder {
return &AppBuilder{ctx: ctx}
}
func (b *AppBuilder) UseConfig(cfg *config.ALRConfig) *AppBuilder {
if b.err != nil {
return b
}
b.deps.Cfg = cfg
return b
}
func (b *AppBuilder) WithConfig() *AppBuilder {
if b.err != nil {
return b
@ -92,16 +100,21 @@ func (b *AppBuilder) WithDB() *AppBuilder {
}
func (b *AppBuilder) WithRepos() *AppBuilder {
b.withRepos(false)
b.withRepos(true, false)
return b
}
func (b *AppBuilder) WithReposForcePull() *AppBuilder {
b.withRepos(true)
b.withRepos(true, true)
return b
}
func (b *AppBuilder) withRepos(forcePull bool) *AppBuilder {
func (b *AppBuilder) WithReposNoPull() *AppBuilder {
b.withRepos(false, false)
return b
}
func (b *AppBuilder) withRepos(enablePull, forcePull bool) *AppBuilder {
if b.err != nil {
return b
}
@ -115,7 +128,7 @@ func (b *AppBuilder) withRepos(forcePull bool) *AppBuilder {
rs := repos.New(cfg, db)
if forcePull || cfg.AutoPull() {
if enablePull && (forcePull || cfg.AutoPull()) {
if err := rs.Pull(b.ctx, cfg.Repos()); err != nil {
slog.Error(gotext.Get("Error pulling repositories"), "err", err)
b.err = cli.Exit("", 1)