Reimplement getpkgbuild

Futre todos:
	Add option to fetch deps
	Add option to set download path
This commit is contained in:
morganamilo 2018-01-03 19:17:57 +00:00
parent 68a9771327
commit 3084f91ba7
No known key found for this signature in database
GPG key ID: 6FE9E7996B0B082E
2 changed files with 22 additions and 4 deletions

16
cmd.go
View file

@ -241,6 +241,8 @@ func handleCmd(parser *argParser) (changedConfig bool, err error) {
passToPacman(parser)
case "U", "upgrade":
passToPacman(parser)
case "G", "getpkgbuild":
err = handleGetpkgbuild(parser)
case "Y", "--yay":
err = handleYay(parser)
default:
@ -349,6 +351,20 @@ func handleYay(parser *argParser) (err error) {
return
}
func handleGetpkgbuild(parser *argParser) (err error) {
for pkg := range parser.targets {
err = getPkgbuild(pkg)
if err != nil {
//we print the error instead of returning it
//seems as we can handle multiple errors without stoping
//theres no easy way arround this right now
fmt.Println(pkg + ":", err)
}
}
return
}
func handleYogurt(parser *argParser) (err error) {
// TODO
// _, options, targets := parser.formatArgs()

View file

@ -7,19 +7,21 @@ import (
"io"
)
type set map[string]struct{}
type argParser struct {
op string
options map[string]string
doubles map[string]struct{} //tracks args passed twice such as -yy and -dd
targets map[string]struct{}
doubles set //tracks args passed twice such as -yy and -dd
targets set
}
func makeArgParser() *argParser {
return &argParser {
"",
make(map[string]string),
make(map[string]struct{}),
make(map[string]struct{}),
make(set),
make(set),
}
}