Refactored

This commit is contained in:
Jguer 2016-11-30 13:59:38 +00:00
parent 517939d108
commit d490f484ca
3 changed files with 11 additions and 11 deletions

View File

@ -26,7 +26,7 @@ func NumberMenu(pkgName string, flags []string) (err error) {
var args []string var args []string
a, err := aur.Search(pkgName, true) a, err := aur.Search(pkgName, true)
r, err := SearchPackages(pkgName, conf) r, err := SearchPackages(pkgName)
if err != nil { if err != nil {
return return
} }
@ -76,7 +76,7 @@ func NumberMenu(pkgName string, flags []string) (err error) {
} }
for _, aurpkg := range aurInstall { for _, aurpkg := range aurInstall {
err = aurpkg.Install(BuildDir, conf, flags) err = aurpkg.Install(BuildDir, &conf, flags)
if err != nil { if err != nil {
// Do not abandon program, we might still be able to install the rest // Do not abandon program, we might still be able to install the rest
fmt.Println(err) fmt.Println(err)
@ -133,7 +133,7 @@ func Install(pkgs []string, flags []string) error {
} }
for _, aurpkg := range foreign { for _, aurpkg := range foreign {
err = aur.Install(aurpkg, BuildDir, conf, flags) err = aur.Install(aurpkg, BuildDir, &conf, flags)
} }
return nil return nil
@ -142,7 +142,7 @@ func Install(pkgs []string, flags []string) error {
// Upgrade handles updating the cache and installing updates. // Upgrade handles updating the cache and installing updates.
func Upgrade(flags []string) error { func Upgrade(flags []string) error {
errp := UpdatePackages(flags) errp := UpdatePackages(flags)
erra := aur.UpdatePackages(BuildDir, conf, flags) erra := aur.UpdatePackages(BuildDir, &conf, flags)
if errp != nil { if errp != nil {
return errp return errp
@ -158,7 +158,7 @@ func Search(pkg string) (err error) {
return err return err
} }
SearchRepos(pkg, conf, SearchMode) SearchRepos(pkg, SearchMode)
a.PrintSearch(SearchMode) a.PrintSearch(SearchMode)
return nil return nil

View File

@ -68,21 +68,21 @@ func main() {
err = yay.LocalStatistics() err = yay.LocalStatistics()
case "-Ss": case "-Ss":
for _, pkg := range pkgs { for _, pkg := range pkgs {
err = searchMode(pkg, &conf) err = yay.Search(pkg)
} }
case "-S": case "-S":
err = InstallPackage(pkgs, &conf, options) err = yay.Install(pkgs, options)
case "-Syu", "-Suy": case "-Syu", "-Suy":
err = yay.Upgrade(options) err = yay.Upgrade(options)
case "yogurt": case "yogurt":
for _, pkg := range pkgs { for _, pkg := range pkgs {
err = yay.NumberMenu(pkg, &conf, options) err = yay.NumberMenu(pkg, options)
break break
} }
case "--help", "-h": case "--help", "-h":
usage() usage()
default: default:
err = passToPacman(op, pkgs, options) err = yay.PassToPacman(op, pkgs, options)
} }
if err != nil { if err != nil {

View File

@ -61,7 +61,7 @@ func UpdatePackages(flags []string) error {
} }
// SearchRepos searches and prints packages in repo // SearchRepos searches and prints packages in repo
func SearchRepos(pkgName string, conf *alpm.PacmanConfig, mode int) (err error) { func SearchRepos(pkgName string, mode int) (err error) {
h, err := conf.CreateHandle() h, err := conf.CreateHandle()
defer h.Release() defer h.Release()
if err != nil { if err != nil {
@ -103,7 +103,7 @@ func SearchRepos(pkgName string, conf *alpm.PacmanConfig, mode int) (err error)
} }
// SearchPackages handles repo searches. Creates a RepoSearch struct. // SearchPackages handles repo searches. Creates a RepoSearch struct.
func SearchPackages(pkgName string, conf *alpm.PacmanConfig) (s RepoSearch, err error) { func SearchPackages(pkgName string) (s RepoSearch, err error) {
h, err := conf.CreateHandle() h, err := conf.CreateHandle()
defer h.Release() defer h.Release()
if err != nil { if err != nil {