Correctly set config.AURURL after parsing flags

And also honour aururl during -Pc
This commit is contained in:
morganamilo 2018-08-19 05:53:32 +01:00
parent 0454e8918b
commit 2f545c7fdc
No known key found for this signature in database
GPG key ID: 6FE9E7996B0B082E
3 changed files with 6 additions and 11 deletions

View file

@ -13,7 +13,7 @@ import (
//CreateAURList creates a new completion file //CreateAURList creates a new completion file
func createAURList(out *os.File) (err error) { func createAURList(out *os.File) (err error) {
resp, err := http.Get("https://aur.archlinux.org/packages.gz") resp, err := http.Get(config.AURURL + "/packages.gz")
if err != nil { if err != nil {
return err return err
} }

10
main.go
View file

@ -4,13 +4,10 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"os" "os"
"path"
"path/filepath" "path/filepath"
"strings" "strings"
"net/url"
alpm "github.com/jguer/go-alpm" alpm "github.com/jguer/go-alpm"
rpc "github.com/mikkeloscar/aur"
) )
func setPaths() error { func setPaths() error {
@ -50,13 +47,6 @@ 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 return nil
} }

View file

@ -9,6 +9,8 @@ import (
"strconv" "strconv"
"strings" "strings"
"unicode" "unicode"
rpc "github.com/mikkeloscar/aur"
) )
// A basic set implementation for strings. // A basic set implementation for strings.
@ -873,6 +875,9 @@ func (parser *arguments) extractYayOptions() {
parser.delArg(option) parser.delArg(option)
} }
} }
rpc.AURURL = strings.TrimRight(config.AURURL, "/") + "/rpc.php?"
config.AURURL = strings.TrimRight(config.AURURL, "/")
} }
//parses input for number menus splitted by spaces or commas //parses input for number menus splitted by spaces or commas