Merge pull request #136 from reesmichael1/prettify

Prettify repository download messages
This commit is contained in:
J Guerreiro 2018-02-06 12:33:12 +00:00 committed by GitHub
commit fb8297881f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 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,36 @@ 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() + " "
}
repoInfo := boldBlueFg(
"[" + repoType + ", " + strconv.Itoa(len(repo)) + " packages] ")
if len(repo) > 0 {
printDownloads(repoInfo, packages)
}
}
// printDownloadsFromAur prints AUR packages to be downloaded
func printDownloadsFromAur(repoType string, repo []*rpc.Pkg) {
var packages string
for _, v := range repo {
packages += v.Name + " "
}
repoInfo := redFg(
"[" + repoType + ", " + strconv.Itoa(len(repo)) + " packages] ")
if len(repo) > 0 {
printDownloads(repoInfo, packages)
}
}
func printDownloads(repoInfo, packages string) {
fmt.Println(repoInfo + yellowFg(packages))
}
func printDeps(repoDeps []string, aurDeps []string) {
if len(repoDeps) != 0 {
fmt.Print(boldGreenFg(arrow + " Repository dependencies: "))