feat: add autoPull in config

This commit is contained in:
2025-01-22 18:10:57 +03:00
parent 30f95a4cbf
commit 309ecf784f
9 changed files with 115 additions and 80 deletions

15
info.go
View File

@ -52,6 +52,11 @@ func InfoCmd() *cli.Command {
cfg := config.New()
db := db.New(cfg)
err := db.Init(ctx)
if err != nil {
slog.Error(gotext.Get("Error initialization database"), "err", err)
os.Exit(1)
}
rs := repos.New(cfg, db)
args := c.Args()
@ -60,10 +65,12 @@ func InfoCmd() *cli.Command {
os.Exit(1)
}
err := rs.Pull(ctx, cfg.Repos(ctx))
if err != nil {
slog.Error(gotext.Get("Error pulling repositories"))
os.Exit(1)
if cfg.AutoPull(ctx) {
err := rs.Pull(ctx, cfg.Repos(ctx))
if err != nil {
slog.Error(gotext.Get("Error pulling repos"), "err", err)
os.Exit(1)
}
}
found, _, err := rs.FindPkgs(ctx, args.Slice())