mirror of
https://github.com/Jguer/yay.git
synced 2024-11-07 01:27:21 +01:00
Refactored
This commit is contained in:
parent
517939d108
commit
d490f484ca
10
actions.go
10
actions.go
@ -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
|
||||||
|
@ -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 {
|
||||||
|
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user