Skip to content

Commit

Permalink
fix(query): reduce verbosity of -Qu (#2060)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jguer authored Apr 3, 2023
1 parent c78d031 commit 0892fc7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
4 changes: 4 additions & 0 deletions pkg/db/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"time"

alpm "github.com/Jguer/go-alpm/v2"

"github.com/Jguer/yay/v12/pkg/text"
)

type (
Expand Down Expand Up @@ -59,4 +61,6 @@ type Executor interface {
SyncPackages(...string) []IPackage
SyncSatisfier(string) IPackage
SyncSatisfierExists(string) bool

SetLogger(logger *text.Logger)
}
6 changes: 6 additions & 0 deletions pkg/db/ialpm/high_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package ialpm

import (
alpm "github.com/Jguer/go-alpm/v2"

"github.com/Jguer/yay/v12/pkg/text"
)

// GetPackageNamesBySource returns package names with and without correspondence in SyncDBS respectively.
Expand Down Expand Up @@ -43,3 +45,7 @@ func (ae *AlpmExecutor) InstalledSyncPackageNames() []string {

return ae.installedSyncPkgNames
}

func (ae *AlpmExecutor) SetLogger(logger *text.Logger) {
ae.log = logger
}
9 changes: 5 additions & 4 deletions pkg/upgrade/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func UpDevel(
for pkgName, pkg := range remote {
if localCache.ToUpgrade(ctxTimeout, pkgName) {
if _, ok := aurdata[pkgName]; !ok {
text.Warnln(gotext.Get("ignoring package devel upgrade (no AUR info found):"), pkgName)
log.Warnln(gotext.Get("ignoring package devel upgrade (no AUR info found):"), pkgName)
continue
}

Expand All @@ -53,11 +53,12 @@ func UpDevel(
return toUpgrade
}

func printIgnoringPackage(logger *text.Logger, pkg db.IPackage, newPkgVersion string) {
func printIgnoringPackage(log *text.Logger, pkg db.IPackage, newPkgVersion string) {
left, right := GetVersionDiff(pkg.Version(), newPkgVersion)

logger.Warnln(gotext.Get("%s: ignoring package upgrade (%s => %s)",
text.Cyan(pkg.Name()),
pkgName := pkg.Name()
log.Warnln(gotext.Get("%s: ignoring package upgrade (%s => %s)",
text.Cyan(pkgName),
left, right,
))
}
Expand Down
11 changes: 5 additions & 6 deletions print.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,9 @@ func printUpdateList(ctx context.Context, cfg *settings.Configuration, cmdArgs *
dbExecutor db.Executor, enableDowngrade bool, filter upgrade.Filter,
) error {
quietMode := cmdArgs.ExistsArg("q", "quiet")
logger := cfg.Runtime.Logger.Child("update-list")
if quietMode { // TODO: handle quiet mode in a better way
logger = text.NewLogger(io.Discard, os.Stdin, cfg.Debug, "update-list")
}
// TODO: handle quiet mode in a better way
logger := text.NewLogger(io.Discard, os.Stdin, cfg.Debug, "update-list")
dbExecutor.SetLogger(logger.Child("db"))

targets := mapset.NewThreadUnsafeSet(cmdArgs.Targets...)
grapher := dep.NewGrapher(dbExecutor, cfg.Runtime.AURCache, false, settings.NoConfirm,
Expand Down Expand Up @@ -141,8 +140,8 @@ func printUpdateList(ctx context.Context, cfg *settings.Configuration, cmdArgs *
if quietMode {
fmt.Printf("%s\n", pkgName)
} else {
fmt.Printf("%s %s -> %s\n", text.Bold(pkgName), text.Green(ii.LocalVersion),
text.Green(ii.Version))
fmt.Printf("%s %s -> %s\n", text.Bold(pkgName), text.Bold(text.Green(ii.LocalVersion)),
text.Bold(text.Green(ii.Version)))
}

targets.Remove(pkgName)
Expand Down

0 comments on commit 0892fc7

Please sign in to comment.