mirror of
https://github.com/Jguer/yay
synced 2024-08-31 05:39:29 +00:00
Expand environment variables in config
This commit is contained in:
parent
b757d0abd3
commit
8c1658df0b
5
cmd.go
5
cmd.go
|
@ -132,6 +132,8 @@ func handleCmd() (err error) {
|
|||
config.saveConfig()
|
||||
}
|
||||
|
||||
config.expandEnv()
|
||||
|
||||
if cmdArgs.existsArg("h", "help") {
|
||||
err = handleHelp()
|
||||
return
|
||||
|
@ -196,7 +198,8 @@ func handlePrint() (err error) {
|
|||
switch {
|
||||
case cmdArgs.existsArg("d", "defaultconfig"):
|
||||
var tmpConfig Configuration
|
||||
defaultSettings(&tmpConfig)
|
||||
tmpConfig.defaultSettings()
|
||||
tmpConfig.expandEnv()
|
||||
fmt.Printf("%v", tmpConfig)
|
||||
case cmdArgs.existsArg("g", "currentconfig"):
|
||||
fmt.Printf("%v", config)
|
||||
|
|
35
config.go
35
config.go
|
@ -146,9 +146,14 @@ func (config *Configuration) saveConfig() error {
|
|||
return err
|
||||
}
|
||||
|
||||
func defaultSettings(config *Configuration) {
|
||||
func (config *Configuration) defaultSettings() {
|
||||
buildDir := "$HOME/.config/yay"
|
||||
if os.Getenv("XDG_CONFIG_HOME") != "" {
|
||||
buildDir = "$XDG_CONFIG_HOME/yay"
|
||||
}
|
||||
|
||||
config.AURURL = "https://aur.archlinux.org"
|
||||
config.BuildDir = cacheHome
|
||||
config.BuildDir = buildDir
|
||||
config.CleanAfter = false
|
||||
config.Editor = ""
|
||||
config.EditorFlags = ""
|
||||
|
@ -188,6 +193,32 @@ func defaultSettings(config *Configuration) {
|
|||
config.CombinedUpgrade = false
|
||||
}
|
||||
|
||||
|
||||
func (config *Configuration) expandEnv() {
|
||||
config.AURURL = os.ExpandEnv(config.AURURL)
|
||||
config.BuildDir = os.ExpandEnv(config.BuildDir)
|
||||
config.Editor = os.ExpandEnv(config.Editor)
|
||||
config.EditorFlags = os.ExpandEnv(config.EditorFlags)
|
||||
config.MakepkgBin = os.ExpandEnv(config.MakepkgBin)
|
||||
config.MakepkgConf = os.ExpandEnv(config.MakepkgConf)
|
||||
config.PacmanBin = os.ExpandEnv(config.PacmanBin)
|
||||
config.PacmanConf = os.ExpandEnv(config.PacmanConf)
|
||||
config.GpgFlags = os.ExpandEnv(config.GpgFlags)
|
||||
config.MFlags = os.ExpandEnv(config.MFlags)
|
||||
config.GitFlags = os.ExpandEnv(config.GitFlags)
|
||||
config.SortBy = os.ExpandEnv(config.SortBy)
|
||||
config.TarBin = os.ExpandEnv(config.TarBin)
|
||||
config.GitBin = os.ExpandEnv(config.GitBin)
|
||||
config.GpgBin = os.ExpandEnv(config.GpgBin)
|
||||
config.ReDownload = os.ExpandEnv(config.ReDownload)
|
||||
config.ReBuild = os.ExpandEnv(config.ReBuild)
|
||||
config.AnswerClean = os.ExpandEnv(config.AnswerClean)
|
||||
config.AnswerDiff = os.ExpandEnv(config.AnswerDiff)
|
||||
config.AnswerEdit = os.ExpandEnv(config.AnswerEdit)
|
||||
config.AnswerUpgrade = os.ExpandEnv(config.AnswerUpgrade)
|
||||
config.RemoveMake = os.ExpandEnv(config.RemoveMake)
|
||||
}
|
||||
|
||||
// Editor returns the preferred system editor.
|
||||
func editor() (string, []string) {
|
||||
switch {
|
||||
|
|
Loading…
Reference in a new issue