1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Properly scope Config to the wtf package and remove it as a dependency from everywhere else

This commit is contained in:
Chris Cummer
2018-06-16 14:59:22 -07:00
parent abedee0ce0
commit 66b69471d0
42 changed files with 126 additions and 251 deletions

View File

@@ -21,10 +21,10 @@ func (widget *Widget) display() {
str = str + widget.displayStats(project)
str = str + "\n"
str = str + " [red]Open Approval Requests[white]\n"
str = str + widget.displayMyApprovalRequests(project, Config.UString("wtf.mods.gitlab.username"))
str = str + widget.displayMyApprovalRequests(project, wtf.Config.UString("wtf.mods.gitlab.username"))
str = str + "\n"
str = str + " [red]My Merge Requests[white]\n"
str = str + widget.displayMyMergeRequests(project, Config.UString("wtf.mods.gitlab.username"))
str = str + widget.displayMyMergeRequests(project, wtf.Config.UString("wtf.mods.gitlab.username"))
widget.View.SetText(str)
}

View File

@@ -4,15 +4,11 @@ import (
"os"
"github.com/gdamore/tcell"
"github.com/olebedev/config"
"github.com/rivo/tview"
"github.com/senorprogrammer/wtf/wtf"
glb "github.com/xanzy/go-gitlab"
)
// Config is a pointer to the global config object
var Config *config.Config
const HelpText = `
Keyboard commands for Gitlab:
@@ -39,7 +35,7 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
apiKey := os.Getenv("WTF_GITLAB_TOKEN")
baseURL := Config.UString("wtf.mods.gitlab.domain")
baseURL := wtf.Config.UString("wtf.mods.gitlab.domain")
gitlab := glb.NewClient(nil, apiKey)
if baseURL != "" {
gitlab.SetBaseURL(baseURL)
@@ -56,7 +52,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
Idx: 0,
}
widget.GitlabProjects = widget.buildProjectCollection(Config.UMap("wtf.mods.gitlab.projects"))
widget.GitlabProjects = widget.buildProjectCollection(wtf.Config.UMap("wtf.mods.gitlab.projects"))
widget.View.SetInputCapture(widget.keyboardIntercept)