References #39, Sy

This commit is contained in:
Jguer 2017-07-24 10:32:11 +01:00
parent f80e3130ab
commit 6165007f2c
2 changed files with 45 additions and 0 deletions

39
install/i.go Normal file
View file

@ -0,0 +1,39 @@
package install
import "fmt"
// Install sends system commands to make and install a package from pkgName
func Install(pkgName []string, flags []string) (err error) {
q, err := rpc.Info(pkgName)
if err != nil {
return
}
if len(q) != len(pkgName) {
fmt.Printf("Some package from list\n%+v\ndoes not exist", pkgName)
}
var finalrm []string
for _, i := range q {
mrm, err := PkgInstall(&i, flags)
if err != nil {
fmt.Println("Error installing", i.Name, ":", err)
}
finalrm = append(finalrm, mrm...)
}
if len(finalrm) != 0 {
err = RemoveMakeDeps(finalrm)
}
return err
}
// PkgInstall handles install from Info Result.
func PkgInstall(a []*rpc.Pkg, flags []string) (finalmdeps []string, err error) {
for _, pkg := range a {
if pkg.Maintainer == "" {
fmt.Println("\x1b[1;31;40m==> Warning:\x1b[0;;40m This package is orphaned.\x1b[0m")
}
}
}

6
yay.go
View file

@ -142,6 +142,12 @@ func main() {
} }
case "-S": case "-S":
err = install(pkgs, options) err = install(pkgs, options)
case "-Sy":
err = config.PassToPacman("-Sy", nil, nil)
if err != nil {
break
}
err = install(pkgs, options)
case "-Syu", "-Suy", "-Su": case "-Syu", "-Suy", "-Su":
if strings.Contains(op, "y") { if strings.Contains(op, "y") {
err = config.PassToPacman("-Sy", nil, nil) err = config.PassToPacman("-Sy", nil, nil)