forked from Plemya-x/ALR
refactor
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user