mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Handle historical config
Parse repositories both ways Have github manually set sources, since historical config may not handle
This commit is contained in:
parent
85014a4ded
commit
cb64f7df22
@ -1,6 +1,7 @@
|
||||
package github
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/olebedev/config"
|
||||
@ -29,10 +30,25 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
||||
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_GITHUB_TOKEN")),
|
||||
baseURL: ymlConfig.UString("baseURL", os.Getenv("WTF_GITHUB_BASE_URL")),
|
||||
enableStatus: ymlConfig.UBool("enableStatus", false),
|
||||
repositories: wtf.ToStrs(ymlConfig.UList("repositories")),
|
||||
uploadURL: ymlConfig.UString("uploadURL", os.Getenv("WTF_GITHUB_UPLOAD_URL")),
|
||||
username: ymlConfig.UString("username"),
|
||||
}
|
||||
settings.repositories = parseRepositories(ymlConfig)
|
||||
|
||||
return &settings
|
||||
}
|
||||
|
||||
func parseRepositories(ymlConfig *config.Config) []string {
|
||||
|
||||
result := []string{}
|
||||
repositories, err := ymlConfig.Map("repositories")
|
||||
if err == nil {
|
||||
for key, value := range repositories {
|
||||
result = append(result, fmt.Sprintf("%s/%s", value, key))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
result = wtf.ToStrs(ymlConfig.UList("repositories"))
|
||||
return result
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
widget.View.SetInputCapture(widget.InputCapture)
|
||||
widget.SetDisplayFunction(widget.display)
|
||||
|
||||
widget.Sources = widget.settings.repositories
|
||||
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
return &widget
|
||||
|
Loading…
x
Reference in New Issue
Block a user