diff --git a/actions.go b/actions.go index 716014d9..e751f70f 100644 --- a/actions.go +++ b/actions.go @@ -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() @@ -218,9 +241,9 @@ func LocalStatistics(version string) error { if res.Maintainer == "" { fmt.Printf("\x1b[1;31;40mWarning: \x1B[1;33;40m%s\x1b[0;;40m is orphaned.\x1b[0m\n", res.Name) } - if res.OutOfDate != 0 { + if res.OutOfDate != 0 { fmt.Printf("\x1b[1;31;40mWarning: \x1B[1;33;40m%s\x1b[0;;40m is out-of-date in AUR.\x1b[0m\n", res.Name) - } + } } return nil @@ -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...) diff --git a/aur/aur.go b/aur/aur.go index 36703ded..e68027b4 100644 --- a/aur/aur.go +++ b/aur/aur.go @@ -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) { diff --git a/cmd/yay/yay.go b/cmd/yay/yay.go index 609b682f..3b30d1c8 100644 --- a/cmd/yay/yay.go +++ b/cmd/yay/yay.go @@ -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) diff --git a/pacman/pacman.go b/pacman/pacman.go index 7d9ca8cf..173293df 100644 --- a/pacman/pacman.go +++ b/pacman/pacman.go @@ -237,6 +237,7 @@ func PackageSlices(toCheck []string) (aur []string, repo []string, err error) { } } + err = nil return }