Added -Si, ended up fixing serious bug in PackageSlice

This commit is contained in:
Jguer 2016-12-16 02:13:17 +00:00
parent e3ae50dbd5
commit 6ea3bad98a
4 changed files with 86 additions and 3 deletions

View file

@ -183,6 +183,29 @@ func Search(pkg string) (err error) {
return nil
}
// SingleSearch serves as a pacman -Si for repo packages and AUR packages.
func SingleSearch(pkgS []string, flags []string) (err error) {
aurS, repoS, err := pac.PackageSlices(pkgS)
if err != nil {
return
}
q, _, err := aur.MultiInfo(aurS)
if err != nil {
fmt.Println(err)
}
for _, aurP := range q {
aurP.PrintInfo()
}
if len(repoS) != 0 {
err = PassToPacman("-Si", repoS, flags)
}
return
}
// LocalStatistics returns installed packages statistics.
func LocalStatistics(version string) error {
info, err := pac.Statistics()
@ -269,7 +292,7 @@ func PassToPacman(op string, pkgs []string, flags []string) error {
args = append(args, flags...)
}
if strings.Contains(op, "-Q") {
if strings.Contains(op, "-Q") || op == "-Si" {
cmd = exec.Command("pacman", args...)
} else {
args = append([]string{"pacman"}, args...)

View file

@ -383,6 +383,63 @@ func MissingPackage(aurDeps []string, aurQ Query) {
return
}
// PrintInfo prints package info like pacman -Si
func (a *Result) PrintInfo() {
fmt.Println("\x1b[1;37mRepository :\x1b[0m", "aur")
fmt.Println("\x1b[1;37mName :\x1b[0m", a.Name)
fmt.Println("\x1b[1;37mVersion :\x1b[0m", a.Version)
fmt.Println("\x1b[1;37mDescription :\x1b[0m", a.Description)
if a.URL != "" {
fmt.Println("\x1b[1;37mURL :\x1b[0m", a.URL)
} else {
fmt.Println("\x1b[1;37mURL :\x1b[0m", "None")
}
fmt.Println("\x1b[1;37mLicenses :\x1b[0m", a.License)
if len(a.Provides) != 0 {
fmt.Println("\x1b[1;37mProvides :\x1b[0m", a.Provides)
} else {
fmt.Println("\x1b[1;37mProvides :\x1b[0m", "None")
}
if len(a.Depends) != 0 {
fmt.Println("\x1b[1;37mDepends On :\x1b[0m", a.Depends)
} else {
fmt.Println("\x1b[1;37mDepends On :\x1b[0m", "None")
}
if len(a.MakeDepends) != 0 {
fmt.Println("\x1b[1;37mMake depends On :\x1b[0m", a.MakeDepends)
} else {
fmt.Println("\x1b[1;37mMake depends On :\x1b[0m", "None")
}
if len(a.OptDepends) != 0 {
fmt.Println("\x1b[1;37mOptional Deps :\x1b[0m", a.OptDepends)
} else {
fmt.Println("\x1b[1;37mOptional Deps :\x1b[0m", "None")
}
if len(a.Conflicts) != 0 {
fmt.Println("\x1b[1;37mConflicts With :\x1b[0m", a.Conflicts)
} else {
fmt.Println("\x1b[1;37mConflicts With :\x1b[0m", "None")
}
if a.Maintainer != "" {
fmt.Println("\x1b[1;37mMaintainer :\x1b[0m", a.Maintainer)
} else {
fmt.Println("\x1b[1;37mMaintainer :\x1b[0m", "None")
}
fmt.Println("\x1b[1;37mVotes :\x1b[0m", a.NumVotes)
fmt.Println("\x1b[1;37mPopularity :\x1b[0m", a.Popularity)
if a.OutOfDate != 0 {
fmt.Println("\x1b[1;37mOut-of-date :\x1b[0m", "Yes")
}
}
// Dependencies returns package dependencies not installed belonging to AUR
// 0 is Repo, 1 is Foreign.
func (a *Result) Dependencies() (runDeps [2][]string, makeDeps [2][]string, err error) {

View file

@ -90,6 +90,8 @@ func main() {
err = yay.Install(pkgs, options)
case "-Syu", "-Suy":
err = yay.Upgrade(options)
case "-Si":
err = yay.SingleSearch(pkgs, options)
case "yogurt":
for _, pkg := range pkgs {
err = yay.NumberMenu(pkg, options)

View file

@ -237,6 +237,7 @@ func PackageSlices(toCheck []string) (aur []string, repo []string, err error) {
}
}
err = nil
return
}