Add --aururl

This commit is contained in:
morganamilo 2018-08-19 05:05:16 +01:00
parent 23ff1e79df
commit 0454e8918b
No known key found for this signature in database
GPG key ID: 6FE9E7996B0B082E
5 changed files with 20 additions and 7 deletions

View file

@ -35,6 +35,7 @@ const (
// Configuration stores yay's config.
type Configuration struct {
AURURL string `json:"aururl"`
BuildDir string `json:"buildDir"`
Editor string `json:"editor"`
EditorFlags string `json:"editorflags"`
@ -84,9 +85,6 @@ const configFileName string = "config.json"
// vcsFileName holds the name of the vcs file.
const vcsFileName string = "vcs.json"
// baseURL givers the AUR default address.
const baseURL string = "https://aur.archlinux.org"
// useColor enables/disables colored printing
var useColor bool
@ -149,6 +147,7 @@ func (config *Configuration) saveConfig() error {
}
func defaultSettings(config *Configuration) {
config.AURURL = "https://aur.archlinux.org"
config.BuildDir = cacheHome
config.CleanAfter = false
config.Editor = ""

View file

@ -845,7 +845,7 @@ func downloadPkgbuilds(bases []Base, toSkip stringSet, buildDir string) (stringS
}
if shouldUseGit(filepath.Join(config.BuildDir, pkg)) {
clone, err := gitDownload(baseURL+"/"+pkg+".git", buildDir, pkg)
clone, err := gitDownload(config.AURURL+"/"+pkg+".git", buildDir, pkg)
if err != nil {
errs.Add(err)
return
@ -856,7 +856,7 @@ func downloadPkgbuilds(bases []Base, toSkip stringSet, buildDir string) (stringS
mux.Unlock()
}
} else {
err := downloadAndUnpack(baseURL+base.URLPath(), buildDir)
err := downloadAndUnpack(config.AURURL+base.URLPath(), buildDir)
if err != nil {
errs.Add(err)
return

10
main.go
View file

@ -4,10 +4,13 @@ import (
"encoding/json"
"fmt"
"os"
"path"
"path/filepath"
"strings"
"net/url"
alpm "github.com/jguer/go-alpm"
rpc "github.com/mikkeloscar/aur"
)
func setPaths() error {
@ -47,6 +50,13 @@ func initConfig() error {
}
}
url, err := url.Parse(config.AURURL)
if err != nil {
return err
}
url.Path = path.Join(url.Path, "")
rpc.AURURL = url.String() + "/rpc.php?"
return nil
}

View file

@ -414,6 +414,7 @@ func isArg(arg string) bool {
case "x", "regex":
case "machinereadable":
//yay options
case "aururl":
case "save":
case "afterclean":
case "noafterclean":
@ -493,6 +494,8 @@ func isArg(arg string) bool {
func handleConfig(option, value string) bool {
switch option {
case "aururl":
config.AURURL = value
case "save":
shouldSaveConfig = true
case "afterclean":
@ -702,6 +705,7 @@ func hasParam(arg string) bool {
case "gpgdir":
case "color":
//yay params
case "aururl":
case "mflags":
case "gpgflags":
case "gitflags":

View file

@ -285,7 +285,7 @@ func PrintInfo(a *rpc.Pkg) {
printInfoValue("Version", a.Version)
printInfoValue("Description", a.Description)
printInfoValue("URL", a.URL)
printInfoValue("AUR URL", baseURL+"/packages/"+a.Name)
printInfoValue("AUR URL", config.AURURL+"/packages/"+a.Name)
printInfoValue("Groups", strings.Join(a.Groups, " "))
printInfoValue("Licenses", strings.Join(a.License, " "))
printInfoValue("Provides", strings.Join(a.Provides, " "))
@ -310,7 +310,7 @@ func PrintInfo(a *rpc.Pkg) {
printInfoValue("ID", fmt.Sprintf("%d", a.ID))
printInfoValue("Package Base ID", fmt.Sprintf("%d", a.PackageBaseID))
printInfoValue("Package Base", a.PackageBase)
printInfoValue("Snapshot URL", baseURL+a.URLPath)
printInfoValue("Snapshot URL", config.AURURL+a.URLPath)
}
fmt.Println()