Improve printing

Add ( and ) to "installed" to match groups and out of date
Show popularity as well as voted in yogurt mode
Show download and install size in yogurt mode
Remove printing of white and black
Fix incorrect message on number menu
Yellow is now almost never used
Use `v` instead of `r` when printing version
show when a page was marked out of date on search and info
This commit is contained in:
morganamilo 2018-03-02 04:54:38 +00:00
parent ed2c231a72
commit 55bfd619dc
No known key found for this signature in database
GPG key ID: 6FE9E7996B0B082E
7 changed files with 80 additions and 78 deletions

2
cmd.go
View file

@ -579,7 +579,7 @@ func numberMenu(pkgS []string, flags []string) (err error) {
aurQ.printSearch(numpq + 1) aurQ.printSearch(numpq + 1)
} }
fmt.Println(bold(green(arrow) + green(" Packages to not upgrade (eg: 1 2 3, 1-3 or ^4)"))) fmt.Println(bold(green(arrow + " Packages to install (eg: 1 2 3, 1-3 or ^4)")))
fmt.Print(bold(green(arrow + " "))) fmt.Print(bold(green(arrow + " ")))
reader := bufio.NewReader(os.Stdin) reader := bufio.NewReader(os.Stdin)
numberBuf, overflow, err := reader.ReadLine() numberBuf, overflow, err := reader.ReadLine()

View file

@ -142,8 +142,8 @@ func editor() string {
} }
fallthrough fallthrough
default: default:
fmt.Println(bold(red(blackBg("Warning:"))), fmt.Println(bold(red("Warning:")),
bold(yellow(blackBg("$EDITOR"))), white(blackBg("is not set"))) bold(magenta("$EDITOR")), "is not set")
fmt.Println("Please add $EDITOR or to your environment variables.") fmt.Println("Please add $EDITOR or to your environment variables.")
editorLoop: editorLoop:
@ -179,7 +179,7 @@ func continueTask(s string, def string) (cont bool) {
} }
var response string var response string
fmt.Print(bold(green(arrow+" "+s+" ")), bold(white(postFix))) fmt.Print(bold(green(arrow+" "+s+" ")), bold(postFix))
n, err := fmt.Scanln(&response) n, err := fmt.Scanln(&response)
if err != nil || n == 0 { if err != nil || n == 0 {

View file

@ -101,10 +101,10 @@ nextPkg:
errD := downloadAndUnpack(url, path, true) errD := downloadAndUnpack(url, path, true)
if errD != nil { if errD != nil {
fmt.Println(bold(yellow(pkg.Name())), bold(green(errD.Error()))) fmt.Println(bold(magenta(pkg.Name())), bold(green(errD.Error())))
} }
fmt.Println(bold(green(arrow)), bold(green("Downloaded")), bold(yellow(pkg.Name())), bold(green("from ABS"))) fmt.Println(bold(green(arrow)), bold(green("Downloaded")), bold(magenta(pkg.Name())), bold(green("from ABS")))
continue nextPkg continue nextPkg
} }
} }
@ -124,7 +124,7 @@ func getPkgbuildsfromAUR(pkgs []string, dir string) (err error) {
for _, pkg := range aq { for _, pkg := range aq {
downloadAndUnpack(baseURL+aq[0].URLPath, dir, false) downloadAndUnpack(baseURL+aq[0].URLPath, dir, false)
fmt.Println(bold(green(arrow)), bold(green("Downloaded")), bold(yellow(pkg.Name)), bold(green("from AUR"))) fmt.Println(bold(green(arrow)), bold(green("Downloaded")), bold(magenta(pkg.Name)), bold(green("from AUR")))
} }
return return

View file

@ -56,8 +56,8 @@ func install(parser *arguments) error {
//only error if direct targets or deps are missing //only error if direct targets or deps are missing
for missingName := range dt.Missing { for missingName := range dt.Missing {
if !remoteNamesCache.get(missingName) { if !remoteNamesCache.get(missingName) {
return fmt.Errorf(bold(red(blackBg(arrow+" Error: "))) + return fmt.Errorf(bold(red(arrow+" Error: ")) +
blackBg("Could not find all required package")) "Could not find all required package")
} }
} }
@ -106,7 +106,7 @@ func install(parser *arguments) error {
} }
//for _, pkg := range repoTargets { //for _, pkg := range repoTargets {
//arguments.addTarget(pkg) //arguments.addTarget(pkg)
//} //}
if len(dc.Aur) == 0 && len(arguments.targets) == 0 { if len(dc.Aur) == 0 && len(arguments.targets) == 0 {
@ -125,7 +125,6 @@ func install(parser *arguments) error {
return fmt.Errorf("Error installing repo packages.") return fmt.Errorf("Error installing repo packages.")
} }
depArguments := makeArguments() depArguments := makeArguments()
depArguments.addArg("D", "asdeps") depArguments.addArg("D", "asdeps")
@ -301,9 +300,9 @@ func checkForConflicts(dc *depCatagories) error {
fmt.Println( fmt.Println(
red("Package conflicts found:")) red("Package conflicts found:"))
for name, pkgs := range toRemove { for name, pkgs := range toRemove {
str := "\tInstalling " + yellow(name) + " will remove" str := "\tInstalling " + magenta(name) + " will remove"
for pkg := range pkgs { for pkg := range pkgs {
str += " " + yellow(pkg) str += " " + magenta(pkg)
} }
fmt.Println(str) fmt.Println(str)
@ -447,8 +446,8 @@ func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD,
} }
if built { if built {
fmt.Println(bold(red(blackBg(arrow+" Warning:"))), fmt.Println(bold(red(arrow+" Warning:")),
blackBg(pkg.Name+"-"+pkg.Version+" Already made -- skipping build")) pkg.Name+"-"+pkg.Version+" Already made -- skipping build")
} else { } else {
err := passToMakepkg(dir, "-Ccf", "--noconfirm") err := passToMakepkg(dir, "-Ccf", "--noconfirm")
if err != nil { if err != nil {

View file

@ -5,6 +5,7 @@ import (
"os" "os"
"strconv" "strconv"
"strings" "strings"
"time"
alpm "github.com/jguer/go-alpm" alpm "github.com/jguer/go-alpm"
rpc "github.com/mikkeloscar/aur" rpc "github.com/mikkeloscar/aur"
@ -33,28 +34,30 @@ func (q aurQuery) printSearch(start int) {
var toprint string var toprint string
if config.SearchMode == NumberMenu { if config.SearchMode == NumberMenu {
if config.SortMode == BottomUp { if config.SortMode == BottomUp {
toprint += yellow(strconv.Itoa(len(q)+start-i-1) + " ") toprint += magenta(strconv.Itoa(len(q)+start-i-1) + " ")
} else { } else {
toprint += yellow(strconv.Itoa(start+i) + " ") toprint += magenta(strconv.Itoa(start+i) + " ")
} }
} else if config.SearchMode == Minimal { } else if config.SearchMode == Minimal {
fmt.Println(res.Name) fmt.Println(res.Name)
continue continue
} }
toprint += bold(colourHash("aur")) + "/" + bold(yellow(res.Name)) +
" " + bold(cyan(res.Version)) + toprint += bold(colourHash("aur")) + "/" + bold(res.Name) +
" (" + strconv.Itoa(res.NumVotes) + ") " " " + cyan(res.Version) +
bold(" (+"+strconv.Itoa(res.NumVotes)) +
" " + bold(strconv.FormatFloat(res.Popularity, 'f', 2, 64)+"%) ")
if res.Maintainer == "" { if res.Maintainer == "" {
toprint += red(blackBg("(Orphaned)")) + " " toprint += bold(red("(Orphaned)")) + " "
} }
if res.OutOfDate != 0 { if res.OutOfDate != 0 {
toprint += red(blackBg("(Out-of-date)")) + " " toprint += bold(red("(Out-of-date "+formatTime(res.OutOfDate)+")")) + " "
} }
if _, err := localDb.PkgByName(res.Name); err == nil { if _, err := localDb.PkgByName(res.Name); err == nil {
toprint += green(blackBg("Installed")) toprint += bold(green("(Installed)"))
} }
toprint += "\n " + res.Description toprint += "\n " + res.Description
fmt.Println(toprint) fmt.Println(toprint)
@ -67,16 +70,19 @@ func (s repoQuery) printSearch() {
var toprint string var toprint string
if config.SearchMode == NumberMenu { if config.SearchMode == NumberMenu {
if config.SortMode == BottomUp { if config.SortMode == BottomUp {
toprint += yellow(strconv.Itoa(len(s)-i) + " ") toprint += magenta(strconv.Itoa(len(s)-i) + " ")
} else { } else {
toprint += yellow(strconv.Itoa(i+1) + " ") toprint += magenta(strconv.Itoa(i+1) + " ")
} }
} else if config.SearchMode == Minimal { } else if config.SearchMode == Minimal {
fmt.Println(res.Name()) fmt.Println(res.Name())
continue continue
} }
toprint += colourHash(res.DB().Name()) + "/" + bold(yellow(res.Name())) +
" " + bold(cyan(res.Version())) + " " toprint += bold(colourHash(res.DB().Name())) + "/" + bold(res.Name()) +
" " + cyan(res.Version()) +
bold(" ("+human(res.Size())+
" "+human(res.ISize())+") ")
if len(res.Groups().Slice()) != 0 { if len(res.Groups().Slice()) != 0 {
toprint += fmt.Sprint(res.Groups().Slice(), " ") toprint += fmt.Sprint(res.Groups().Slice(), " ")
@ -85,7 +91,7 @@ func (s repoQuery) printSearch() {
localDb, err := alpmHandle.LocalDb() localDb, err := alpmHandle.LocalDb()
if err == nil { if err == nil {
if _, err = localDb.PkgByName(res.Name()); err == nil { if _, err = localDb.PkgByName(res.Name()); err == nil {
toprint += green(blackBg("Installed")) toprint += bold(green("(Installed)"))
} }
} }
@ -185,27 +191,27 @@ func printDownloads(repoName string, length int, packages string) {
repoInfo := bold(blue( repoInfo := bold(blue(
"[" + repoName + ": " + strconv.Itoa(length) + "]")) "[" + repoName + ": " + strconv.Itoa(length) + "]"))
fmt.Println(repoInfo + yellow(packages)) fmt.Println(repoInfo + magenta(packages))
} }
// PrintInfo prints package info like pacman -Si. // PrintInfo prints package info like pacman -Si.
func PrintInfo(a *rpc.Pkg) { func PrintInfo(a *rpc.Pkg) {
fmt.Println(bold(white("Repository :")), "aur") fmt.Println(bold("Repository :"), "aur")
fmt.Println(bold(white("Name :")), a.Name) fmt.Println(bold("Name :"), a.Name)
fmt.Println(bold(white("Version :")), a.Version) fmt.Println(bold("Version :"), a.Version)
fmt.Println(bold(white("Description :")), a.Description) fmt.Println(bold("Description :"), a.Description)
fmt.Println(bold(white("URL :")), a.URL) fmt.Println(bold("URL :"), a.URL)
fmt.Println(bold(white("Licenses :")), strings.Join(a.License, " ")) fmt.Println(bold("Licenses :"), strings.Join(a.License, " "))
fmt.Println(bold(white("Depends On :")), strings.Join(a.Depends, " ")) fmt.Println(bold("Depends On :"), strings.Join(a.Depends, " "))
fmt.Println(bold(white("Make Deps :")), strings.Join(a.MakeDepends, " ")) fmt.Println(bold("Make Deps :"), strings.Join(a.MakeDepends, " "))
fmt.Println(bold(white("Check Deps :")), strings.Join(a.CheckDepends, " ")) fmt.Println(bold("Check Deps :"), strings.Join(a.CheckDepends, " "))
fmt.Println(bold(white("Optional Deps :")), strings.Join(a.OptDepends, " ")) fmt.Println(bold("Optional Deps :"), strings.Join(a.OptDepends, " "))
fmt.Println(bold(white("Conflicts With :")), strings.Join(a.Conflicts, " ")) fmt.Println(bold("Conflicts With :"), strings.Join(a.Conflicts, " "))
fmt.Println(bold(white("Maintainer :")), a.Maintainer) fmt.Println(bold("Maintainer :"), a.Maintainer)
fmt.Println(bold(white("Votes :")), a.NumVotes) fmt.Println(bold("Votes :"), a.NumVotes)
fmt.Println(bold(white("Popularity :")), a.Popularity) fmt.Println(bold("Popularity :"), a.Popularity)
if a.OutOfDate != 0 { if a.OutOfDate != 0 {
fmt.Println(bold(white("Out-of-date :")), "Yes") fmt.Println(bold("Out-of-date :"), "Yes", "["+formatTime(a.OutOfDate)+"]")
} }
fmt.Println() fmt.Println()
@ -226,7 +232,7 @@ func biggestPackages() {
} }
for i := 0; i < 10; i++ { for i := 0; i < 10; i++ {
fmt.Println(pkgS[i].Name() + ": " + yellow(human(pkgS[i].ISize()))) fmt.Println(bold(pkgS[i].Name()) + ": " + cyan(human(pkgS[i].ISize())))
} }
// Could implement size here as well, but we just want the general idea // Could implement size here as well, but we just want the general idea
} }
@ -243,14 +249,14 @@ func localStatistics() error {
return err return err
} }
fmt.Printf("\n Yay version r%s\n", version) fmt.Printf(bold("Yay version v%s\n"), version)
fmt.Println(bold(cyan("==========================================="))) fmt.Println(bold(cyan("===========================================")))
fmt.Println(bold(green("Total installed packages: ")) + yellow(strconv.Itoa(info.Totaln))) fmt.Println(bold(green("Total installed packages: ")) + magenta(strconv.Itoa(info.Totaln)))
fmt.Println(bold(green("Total foreign installed packages: ")) + yellow(strconv.Itoa(len(remoteNames)))) fmt.Println(bold(green("Total foreign installed packages: ")) + magenta(strconv.Itoa(len(remoteNames))))
fmt.Println(bold(green("Explicitly installed packages: ")) + yellow(strconv.Itoa(info.Expln))) fmt.Println(bold(green("Explicitly installed packages: ")) + magenta(strconv.Itoa(info.Expln)))
fmt.Println(bold(green("Total Size occupied by packages: ")) + yellow(human(info.TotalSize))) fmt.Println(bold(green("Total Size occupied by packages: ")) + magenta(human(info.TotalSize)))
fmt.Println(bold(cyan("==========================================="))) fmt.Println(bold(cyan("===========================================")))
fmt.Println(bold(green("Ten biggest packages"))) fmt.Println(bold(green("Ten biggest packages:")))
biggestPackages() biggestPackages()
fmt.Println(bold(cyan("==========================================="))) fmt.Println(bold(cyan("===========================================")))
@ -299,6 +305,11 @@ func printUpdateList() error {
return nil return nil
} }
func formatTime(i int) string {
t := time.Unix(int64(i), 0)
return fmt.Sprintf("%d/%d/%d", t.Year(), int(t.Month()), t.Day())
}
func red(in string) string { func red(in string) string {
if alpmConf.Options&alpm.ConfColor > 0 { if alpmConf.Options&alpm.ConfColor > 0 {
return "\x1b[31m" + in + "\x1b[0m" return "\x1b[31m" + in + "\x1b[0m"
@ -339,17 +350,9 @@ func cyan(in string) string {
return in return in
} }
func white(in string) string { func magenta(in string) string {
if alpmConf.Options&alpm.ConfColor > 0 { if alpmConf.Options&alpm.ConfColor > 0 {
return "\x1b[37m" + in + "\x1b[0m" return "\x1b[35m" + in + "\x1b[0m"
}
return in
}
func blackBg(in string) string {
if alpmConf.Options&alpm.ConfColor > 0 {
return "\x1b[40m" + in + "\x1b[0m"
} }
return in return in

View file

@ -266,7 +266,7 @@ func hangingPackages() (hanging []string, err error) {
requiredby := pkg.ComputeRequiredBy() requiredby := pkg.ComputeRequiredBy()
if len(requiredby) == 0 { if len(requiredby) == 0 {
hanging = append(hanging, pkg.Name()) hanging = append(hanging, pkg.Name())
fmt.Println(pkg.Name() + ": " + yellow(human(pkg.ISize()))) fmt.Println(pkg.Name() + ": " + magenta(human(pkg.ISize())))
} }
return nil return nil
@ -378,25 +378,25 @@ func aurInfo(names []string) ([]rpc.Pkg, error) {
} }
if len(missing) > 0 { if len(missing) > 0 {
fmt.Print(bold(red(blackBg(arrow + " Missing AUR Packages:")))) fmt.Print(bold(red(arrow + " Missing AUR Packages:")))
for _, name := range missing { for _, name := range missing {
fmt.Print(" " + bold(yellow(blackBg(name)))) fmt.Print(" " + bold(magenta(name)))
} }
fmt.Println() fmt.Println()
} }
if len(orphans) > 0 { if len(orphans) > 0 {
fmt.Print(bold(red(blackBg(arrow + " Orphaned AUR Packages:")))) fmt.Print(bold(red(arrow + " Orphaned AUR Packages:")))
for _, name := range orphans { for _, name := range orphans {
fmt.Print(" " + bold(yellow(blackBg(name)))) fmt.Print(" " + bold(magenta(name)))
} }
fmt.Println() fmt.Println()
} }
if len(outOfDate) > 0 { if len(outOfDate) > 0 {
fmt.Print(bold(red(blackBg(arrow + " Out Of Date AUR Packages:")))) fmt.Print(bold(red(arrow + " Out Of Date AUR Packages:")))
for _, name := range outOfDate { for _, name := range outOfDate {
fmt.Print(" " + bold(yellow(blackBg(name)))) fmt.Print(" " + bold(magenta(name)))
} }
fmt.Println() fmt.Println()
} }

View file

@ -85,8 +85,8 @@ func (u upSlice) Print(start int) {
for k, i := range u { for k, i := range u {
left, right := getVersionDiff(i.LocalVersion, i.RemoteVersion) left, right := getVersionDiff(i.LocalVersion, i.RemoteVersion)
fmt.Print(yellow(fmt.Sprintf("%2d ", len(u)+start-k-1))) fmt.Print(magenta(fmt.Sprintf("%2d ", len(u)+start-k-1)))
fmt.Print(bold(colourHash(i.Repository)), "/", bold(white(i.Name))) fmt.Print(bold(colourHash(i.Repository)), "/", cyan(i.Name))
w := 70 - len(i.Repository) - len(i.Name) + len(left) w := 70 - len(i.Repository) - len(i.Name) + len(left)
fmt.Printf(fmt.Sprintf("%%%ds", w), fmt.Printf(fmt.Sprintf("%%%ds", w),
@ -156,8 +156,8 @@ func upDevel(remote []alpm.Package, packageC chan upgrade, done chan bool) {
} }
if found { if found {
if pkg.ShouldIgnore() { if pkg.ShouldIgnore() {
fmt.Print(yellow("Warning: ")) fmt.Print(magenta("Warning: "))
fmt.Printf("%s ignoring package upgrade (%s => %s)\n", pkg.Name(), pkg.Version(), "git") fmt.Printf("%s ignoring package upgrade (%s => %s)\n", cyan(pkg.Name()), pkg.Version(), "git")
} else { } else {
packageC <- upgrade{e.Package, "devel", pkg.Version(), "commit-" + e.SHA[0:6]} packageC <- upgrade{e.Package, "devel", pkg.Version(), "commit-" + e.SHA[0:6]}
} }
@ -181,7 +181,7 @@ func upAUR(remote []alpm.Package, remoteNames []string, dt *depTree) (toUpgrade
if config.Devel { if config.Devel {
routines++ routines++
go upDevel(remote, packageC, done) go upDevel(remote, packageC, done)
fmt.Println(bold(cyan("::") + "Checking development packages...")) fmt.Println(bold(cyan("::") + "Checking development packages..."))
} }
routines++ routines++
@ -196,8 +196,8 @@ func upAUR(remote []alpm.Package, remoteNames []string, dt *depTree) (toUpgrade
(alpm.VerCmp(pkg.Version(), aurPkg.Version) < 0) { (alpm.VerCmp(pkg.Version(), aurPkg.Version) < 0) {
if pkg.ShouldIgnore() { if pkg.ShouldIgnore() {
left, right := getVersionDiff(pkg.Version(), aurPkg.Version) left, right := getVersionDiff(pkg.Version(), aurPkg.Version)
fmt.Print(yellow("Warning: ")) fmt.Print(magenta("Warning: "))
fmt.Printf("%s ignoring package upgrade (%s => %s)\n", pkg.Name(), left, right) fmt.Printf("%s ignoring package upgrade (%s => %s)\n", cyan(pkg.Name()), left, right)
} else { } else {
packageC <- upgrade{aurPkg.Name, "aur", pkg.Version(), aurPkg.Version} packageC <- upgrade{aurPkg.Name, "aur", pkg.Version(), aurPkg.Version}
} }
@ -245,7 +245,7 @@ func upRepo(local []alpm.Package) (upSlice, error) {
newPkg := pkg.NewVersion(dbList) newPkg := pkg.NewVersion(dbList)
if newPkg != nil { if newPkg != nil {
if pkg.ShouldIgnore() { if pkg.ShouldIgnore() {
fmt.Print(yellow("Warning: ")) fmt.Print(magenta("Warning: "))
fmt.Printf("%s ignoring package upgrade (%s => %s)\n", pkg.Name(), pkg.Version(), newPkg.Version()) fmt.Printf("%s ignoring package upgrade (%s => %s)\n", pkg.Name(), pkg.Version(), newPkg.Version())
} else { } else {
slice = append(slice, upgrade{pkg.Name(), newPkg.DB().Name(), pkg.Version(), newPkg.Version()}) slice = append(slice, upgrade{pkg.Name(), newPkg.DB().Name(), pkg.Version(), newPkg.Version()})
@ -293,12 +293,12 @@ func upgradePkgs(dt *depTree) (stringSet, stringSet, error) {
} }
sort.Sort(repoUp) sort.Sort(repoUp)
fmt.Println(bold(blue("::")), len(aurUp)+len(repoUp), bold(white("Packages to upgrade."))) fmt.Println(bold(blue("::")), len(aurUp)+len(repoUp), bold("Packages to upgrade."))
repoUp.Print(len(aurUp) + 1) repoUp.Print(len(aurUp) + 1)
aurUp.Print(1) aurUp.Print(1)
if !config.NoConfirm { if !config.NoConfirm {
fmt.Println(bold(green(arrow)) + green(" Packages to not upgrade (eg: 1 2 3, 1-3 or ^4)")) fmt.Println(bold(green(arrow + " Packages to not upgrade (eg: 1 2 3, 1-3 or ^4)")))
fmt.Print(bold(green(arrow + " "))) fmt.Print(bold(green(arrow + " ")))
reader := bufio.NewReader(os.Stdin) reader := bufio.NewReader(os.Stdin)