diff --git a/cmd.go b/cmd.go index fe95d55e..88626c2e 100644 --- a/cmd.go +++ b/cmd.go @@ -59,6 +59,7 @@ Permanent configuration options: config file when used --aururl Set an alternative AUR URL + --aurrpcurl Set an alternative URL for the AUR /rpc endpoint --builddir Directory used to download and run PKGBUILDS --editor Editor to use when editing PKGBUILDs --editorflags Pass arguments to editor diff --git a/completions/bash b/completions/bash index c28cbd25..be41c706 100644 --- a/completions/bash +++ b/completions/bash @@ -75,7 +75,7 @@ _yay() { noansweredit noanswerupgrade cleanmenu diffmenu editmenu upgrademenu cleanafter nocleanafter nocleanmenu nodiffmenu noupgrademenu provides noprovides pgpfetch nopgpfetch useask nouseask combinedupgrade nocombinedupgrade aur repo makepkgconf - nomakepkgconf askremovemake removemake noremovemake completioninterval aururl + nomakepkgconf askremovemake removemake noremovemake completioninterval aururl aurrpcurl searchby batchinstall nobatchinstall' 'b d h q r v') yays=('clean gendb' 'c') diff --git a/completions/fish b/completions/fish index 1ff1ed5b..f4cd23c4 100644 --- a/completions/fish +++ b/completions/fish @@ -189,6 +189,7 @@ complete -c $progname -n "$getpkgbuild" -s p -l print -d 'Print pkgbuild of pack # Permanent configuration settings complete -c $progname -n "not $noopt" -l save -d 'Save current arguments to yay permanent configuration' -f complete -c $progname -n "not $noopt" -l aururl -d 'Set an alternative AUR URL' -f +complete -c $progname -n "not $noopt" -l aurrpcurl -d 'Set an alternative URL for the AUR /rpc endpoint' -f complete -c $progname -n "not $noopt" -l builddir -d 'Directory to use for Building AUR Packages' -r complete -c $progname -n "not $noopt" -l editor -d 'Editor to use' -f complete -c $progname -n "not $noopt" -l editorflags -d 'Editor flags to use' -f diff --git a/completions/zsh b/completions/zsh index b81cfee0..38b4292d 100644 --- a/completions/zsh +++ b/completions/zsh @@ -26,6 +26,7 @@ _pacman_opts_common=( '--repo[Assume targets are from the repositories]' {-a,--aur}'[Assume targets are from the AUR]' '--aururl[Set an alternative AUR URL]:url' + '--aurrpcurl[Set an alternative URL for the AUR /rpc endpoint]:url' '--arch[Set an alternate architecture]' {-b,--dbpath}'[Alternate database location]:database_location:_files -/' '--color[colorize the output]:color options:(always never auto)' diff --git a/doc/yay.8 b/doc/yay.8 index 9360278c..27276cb1 100644 --- a/doc/yay.8 +++ b/doc/yay.8 @@ -161,6 +161,10 @@ file. .B \-\-aururl Set an alternative AUR URL. +.TP +.B \-\-aurrpcurl +Set an alternative URL for the AUR /rpc endpoint. + .TP .B \-\-builddir Directory to use for Building AUR Packages. This directory is also used as diff --git a/pkg/settings/args.go b/pkg/settings/args.go index db276f63..2effc2d2 100644 --- a/pkg/settings/args.go +++ b/pkg/settings/args.go @@ -27,14 +27,29 @@ func (c *Configuration) extractYayOptions(a *parser.Arguments) { } } - c.Runtime.AURClient.BaseURL = strings.TrimRight(c.AURURL, "/") + "/rpc?" c.AURURL = strings.TrimRight(c.AURURL, "/") + c.Runtime.AURClient.BaseURL = c.AURURL + "/rpc?" + + // if AurRPCURL is set, use that for /rpc calls + if c.AURRPCURL != "" { + if !strings.HasSuffix(c.AURRPCURL, "?") { + if strings.HasSuffix(c.AURRPCURL, "/rpc") { + c.AURRPCURL += "?" + } else { + c.AURRPCURL = strings.TrimRight(c.AURRPCURL, "/") + "/rpc?" + } + } + + c.Runtime.AURClient.BaseURL = c.AURRPCURL + } } func (c *Configuration) handleOption(option, value string) bool { switch option { case "aururl": c.AURURL = value + case "aurrpcurl": + c.AURRPCURL = value case "save": c.Runtime.SaveConfig = true case "afterclean", "cleanafter": diff --git a/pkg/settings/config.go b/pkg/settings/config.go index bf39cabc..200cd70c 100644 --- a/pkg/settings/config.go +++ b/pkg/settings/config.go @@ -31,6 +31,7 @@ var NoConfirm = false // Configuration stores yay's config. type Configuration struct { AURURL string `json:"aururl"` + AURRPCURL string `json:"aurrpcurl"` BuildDir string `json:"buildDir"` Editor string `json:"editor"` EditorFlags string `json:"editorflags"` @@ -110,6 +111,7 @@ func (c *Configuration) Save(configPath string) error { func (c *Configuration) expandEnv() { c.AURURL = os.ExpandEnv(c.AURURL) + c.AURRPCURL = os.ExpandEnv(c.AURRPCURL) c.BuildDir = os.ExpandEnv(c.BuildDir) c.Editor = os.ExpandEnv(c.Editor) c.EditorFlags = os.ExpandEnv(c.EditorFlags) diff --git a/pkg/settings/parser/parser.go b/pkg/settings/parser/parser.go index 3e264ad1..5329a101 100644 --- a/pkg/settings/parser/parser.go +++ b/pkg/settings/parser/parser.go @@ -373,6 +373,7 @@ func isArg(arg string) bool { case "machinereadable": // yay options case "aururl": + case "aurrpcurl": case "save": case "afterclean", "cleanafter": case "noafterclean", "nocleanafter": @@ -520,6 +521,7 @@ func hasParam(arg string) bool { case "color": // yay params case "aururl": + case "aurrpcurl": case "mflags": case "gpgflags": case "gitflags":