Prettify repository download messages

This commit is contained in:
Michael Rees 2018-02-05 14:05:58 -06:00
parent d2db36ac7a
commit 3df03c3291
No known key found for this signature in database
GPG key ID: 070326141F7D2845
3 changed files with 33 additions and 34 deletions

View file

@ -186,7 +186,7 @@ func continueTask(s string, def string) (cont bool) {
}
var response string
fmt.Print(boldGreenFg(arrow+" "+s), boldWhiteFg(postFix))
fmt.Print(boldGreenFg(arrow+" "+s+" "), boldWhiteFg(postFix))
n, err := fmt.Scanln(&response)
if err != nil || n == 0 {

View file

@ -4,9 +4,7 @@ import (
"fmt"
"os"
"os/exec"
"strconv"
alpm "github.com/jguer/go-alpm"
rpc "github.com/mikkeloscar/aur"
gopkg "github.com/mikkeloscar/gopkgbuild"
)
@ -70,37 +68,10 @@ func install(parser *arguments) error {
}
}
fmt.Println()
p1 := func(a []*alpm.Package) {
for _, v := range a {
fmt.Print(" ", v.Name())
}
}
p2 := func(a []*rpc.Pkg) {
for _, v := range a {
fmt.Print(" ", v.Name)
}
}
fmt.Print("Repo (" + strconv.Itoa(len(dc.Repo)) + "):")
p1(dc.Repo)
fmt.Println()
fmt.Print("Repo Make (" + strconv.Itoa(len(dc.RepoMake)) + "):")
p1(dc.RepoMake)
fmt.Println()
fmt.Print("Aur (" + strconv.Itoa(len(dc.Aur)) + "):")
p2(dc.Aur)
fmt.Println()
fmt.Print("Aur Make (" + strconv.Itoa(len(dc.AurMake)) + "):")
p2(dc.AurMake)
fmt.Println()
fmt.Println()
printDownloadsFromRepo("Repo", dc.Repo)
printDownloadsFromRepo("Repo Make", dc.RepoMake)
printDownloadsFromAur("AUR", dc.Aur)
printDownloadsFromAur("AUR Make", dc.AurMake)
askCleanBuilds(dc.AurMake)
askCleanBuilds(dc.Aur)

View file

@ -94,6 +94,34 @@ func (s repoQuery) printSearch() {
}
}
// printDownloadsFromRepo prints repository packages to be downloaded
func printDownloadsFromRepo(repoType string, repo []*alpm.Package) {
var packages string
for _, v := range repo {
packages += v.Name() + " "
}
if len(repo) > 0 {
printDownloads(repoType, packages, len(repo))
}
}
// printDownloadsFromAur prints AUR packages to be downloaded
func printDownloadsFromAur(repoType string, repo []*rpc.Pkg) {
var packages string
for _, v := range repo {
packages += v.Name + " "
}
if len(repo) > 0 {
printDownloads(repoType, packages, len(repo))
}
}
func printDownloads(repoType, packages string, numPackages int) {
fmt.Println(
redFg("["+repoType+", "+strconv.Itoa(numPackages)+" packages] ") +
yellowFg(packages))
}
func printDeps(repoDeps []string, aurDeps []string) {
if len(repoDeps) != 0 {
fmt.Print(boldGreenFg(arrow + " Repository dependencies: "))