Display missing, orphans and out of date in groups

Instead of printing each warning on a seperate line, group up the
warnings by type (missing, orphan, out of date) and display each
group on its own line.
This commit is contained in:
morganamilo 2018-02-19 05:02:05 +00:00
parent 3f7c731f99
commit 46cc1f2c09
No known key found for this signature in database
GPG key ID: 6FE9E7996B0B082E

View file

@ -373,6 +373,10 @@ func aurInfo(names []string) ([]rpc.Pkg, error) {
var wg sync.WaitGroup
var err error
missing := make([]string, 0, len(names))
orphans := make([]string, 0, len(names))
outOfDate := make([]string, 0, len(names))
makeRequest := func(n, max int) {
tempInfo, requestErr := rpc.Info(names[n:max])
if err != nil {
@ -408,22 +412,43 @@ func aurInfo(names []string) ([]rpc.Pkg, error) {
for _, name := range names {
i, ok := seen[name]
if !ok {
fmt.Println(boldRedFgBlackBg(arrow+"Warning:"),
boldYellowFgBlackBg(name), whiteFgBlackBg("is not available in AUR"))
missing = append(missing, name)
continue
}
pkg := info[i]
if pkg.Maintainer == "" {
fmt.Println(boldRedFgBlackBg(arrow+"Warning:"),
boldYellowFgBlackBg(pkg.Name), whiteFgBlackBg("is orphaned"))
orphans = append(orphans, name)
}
if pkg.OutOfDate != 0 {
fmt.Println(boldRedFgBlackBg(arrow+"Warning:"),
boldYellowFgBlackBg(pkg.Name), whiteFgBlackBg("is out-of-date in AUR"))
outOfDate = append(outOfDate, name)
}
}
if len(missing) > 0 {
fmt.Print(boldRedFgBlackBg(arrow + " Missing AUR Packages:"))
for _, name := range missing {
fmt.Print(" " + boldYellowFgBlackBg(name))
}
fmt.Println()
}
if len(orphans) > 0 {
fmt.Print(boldRedFgBlackBg(arrow + " Orphaned AUR Packages:"))
for _, name := range orphans {
fmt.Print(" " + boldYellowFgBlackBg(name))
}
fmt.Println()
}
if len(outOfDate) > 0 {
fmt.Print(boldRedFgBlackBg(arrow + " Out Of Date AUR Packages:"))
for _, name := range outOfDate {
fmt.Print(" " + boldYellowFgBlackBg(name))
}
fmt.Println()
}
return info, nil
}