add option/setting "AurRpcUrl" (#1809)

Signed-off-by: moson-mo <mo-son@mailbox.org>
This commit is contained in:
moson-mo 2022-09-18 02:05:27 +02:00 committed by GitHub
parent 7f9ac3435f
commit 647d160182
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 28 additions and 2 deletions

1
cmd.go
View file

@ -59,6 +59,7 @@ Permanent configuration options:
config file when used config file when used
--aururl <url> Set an alternative AUR URL --aururl <url> Set an alternative AUR URL
--aurrpcurl <url> Set an alternative URL for the AUR /rpc endpoint
--builddir <dir> Directory used to download and run PKGBUILDS --builddir <dir> Directory used to download and run PKGBUILDS
--editor <file> Editor to use when editing PKGBUILDs --editor <file> Editor to use when editing PKGBUILDs
--editorflags <flags> Pass arguments to editor --editorflags <flags> Pass arguments to editor

View file

@ -75,7 +75,7 @@ _yay() {
noansweredit noanswerupgrade cleanmenu diffmenu editmenu upgrademenu cleanafter nocleanafter noansweredit noanswerupgrade cleanmenu diffmenu editmenu upgrademenu cleanafter nocleanafter
nocleanmenu nodiffmenu noupgrademenu provides noprovides pgpfetch nopgpfetch nocleanmenu nodiffmenu noupgrademenu provides noprovides pgpfetch nopgpfetch
useask nouseask combinedupgrade nocombinedupgrade aur repo makepkgconf useask nouseask combinedupgrade nocombinedupgrade aur repo makepkgconf
nomakepkgconf askremovemake removemake noremovemake completioninterval aururl nomakepkgconf askremovemake removemake noremovemake completioninterval aururl aurrpcurl
searchby batchinstall nobatchinstall' searchby batchinstall nobatchinstall'
'b d h q r v') 'b d h q r v')
yays=('clean gendb' 'c') yays=('clean gendb' 'c')

View file

@ -189,6 +189,7 @@ complete -c $progname -n "$getpkgbuild" -s p -l print -d 'Print pkgbuild of pack
# Permanent configuration settings # 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 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 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 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 editor -d 'Editor to use' -f
complete -c $progname -n "not $noopt" -l editorflags -d 'Editor flags to use' -f complete -c $progname -n "not $noopt" -l editorflags -d 'Editor flags to use' -f

View file

@ -26,6 +26,7 @@ _pacman_opts_common=(
'--repo[Assume targets are from the repositories]' '--repo[Assume targets are from the repositories]'
{-a,--aur}'[Assume targets are from the AUR]' {-a,--aur}'[Assume targets are from the AUR]'
'--aururl[Set an alternative AUR URL]:url' '--aururl[Set an alternative AUR URL]:url'
'--aurrpcurl[Set an alternative URL for the AUR /rpc endpoint]:url'
'--arch[Set an alternate architecture]' '--arch[Set an alternate architecture]'
{-b,--dbpath}'[Alternate database location]:database_location:_files -/' {-b,--dbpath}'[Alternate database location]:database_location:_files -/'
'--color[colorize the output]:color options:(always never auto)' '--color[colorize the output]:color options:(always never auto)'

View file

@ -161,6 +161,10 @@ file.
.B \-\-aururl .B \-\-aururl
Set an alternative AUR URL. Set an alternative AUR URL.
.TP
.B \-\-aurrpcurl
Set an alternative URL for the AUR /rpc endpoint.
.TP .TP
.B \-\-builddir <dir> .B \-\-builddir <dir>
Directory to use for Building AUR Packages. This directory is also used as Directory to use for Building AUR Packages. This directory is also used as

View file

@ -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.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 { func (c *Configuration) handleOption(option, value string) bool {
switch option { switch option {
case "aururl": case "aururl":
c.AURURL = value c.AURURL = value
case "aurrpcurl":
c.AURRPCURL = value
case "save": case "save":
c.Runtime.SaveConfig = true c.Runtime.SaveConfig = true
case "afterclean", "cleanafter": case "afterclean", "cleanafter":

View file

@ -31,6 +31,7 @@ var NoConfirm = false
// Configuration stores yay's config. // Configuration stores yay's config.
type Configuration struct { type Configuration struct {
AURURL string `json:"aururl"` AURURL string `json:"aururl"`
AURRPCURL string `json:"aurrpcurl"`
BuildDir string `json:"buildDir"` BuildDir string `json:"buildDir"`
Editor string `json:"editor"` Editor string `json:"editor"`
EditorFlags string `json:"editorflags"` EditorFlags string `json:"editorflags"`
@ -110,6 +111,7 @@ func (c *Configuration) Save(configPath string) error {
func (c *Configuration) expandEnv() { func (c *Configuration) expandEnv() {
c.AURURL = os.ExpandEnv(c.AURURL) c.AURURL = os.ExpandEnv(c.AURURL)
c.AURRPCURL = os.ExpandEnv(c.AURRPCURL)
c.BuildDir = os.ExpandEnv(c.BuildDir) c.BuildDir = os.ExpandEnv(c.BuildDir)
c.Editor = os.ExpandEnv(c.Editor) c.Editor = os.ExpandEnv(c.Editor)
c.EditorFlags = os.ExpandEnv(c.EditorFlags) c.EditorFlags = os.ExpandEnv(c.EditorFlags)

View file

@ -373,6 +373,7 @@ func isArg(arg string) bool {
case "machinereadable": case "machinereadable":
// yay options // yay options
case "aururl": case "aururl":
case "aurrpcurl":
case "save": case "save":
case "afterclean", "cleanafter": case "afterclean", "cleanafter":
case "noafterclean", "nocleanafter": case "noafterclean", "nocleanafter":
@ -520,6 +521,7 @@ func hasParam(arg string) bool {
case "color": case "color":
// yay params // yay params
case "aururl": case "aururl":
case "aurrpcurl":
case "mflags": case "mflags":
case "gpgflags": case "gpgflags":
case "gitflags": case "gitflags":