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:
@@ -29,7 +29,7 @@ import (
|
||||
func Fetch() ([]*sheets.ValueRange, error) {
|
||||
ctx := context.Background()
|
||||
|
||||
secretPath, _ := wtf.ExpandHomeDir(Config.UString("wtf.mods.gspreadsheets.secretFile"))
|
||||
secretPath, _ := wtf.ExpandHomeDir(wtf.Config.UString("wtf.mods.gspreadsheets.secretFile"))
|
||||
|
||||
b, err := ioutil.ReadFile(secretPath)
|
||||
if err != nil {
|
||||
@@ -51,8 +51,8 @@ func Fetch() ([]*sheets.ValueRange, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cells := wtf.ToStrs(Config.UList("wtf.mods.gspreadsheets.cells.addresses"))
|
||||
documentId := Config.UString("wtf.mods.gspreadsheets.sheetId")
|
||||
cells := wtf.ToStrs(wtf.Config.UList("wtf.mods.gspreadsheets.cells.addresses"))
|
||||
documentId := wtf.Config.UString("wtf.mods.gspreadsheets.sheetId")
|
||||
addresses := strings.Join(cells[:], ";")
|
||||
|
||||
responses := make([]*sheets.ValueRange, len(cells))
|
||||
|
||||
@@ -3,14 +3,10 @@ package gspreadsheets
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/olebedev/config"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
sheets "google.golang.org/api/sheets/v4"
|
||||
)
|
||||
|
||||
// Config is a pointer to the global config object
|
||||
var Config *config.Config
|
||||
|
||||
type Widget struct {
|
||||
wtf.TextWidget
|
||||
}
|
||||
@@ -40,10 +36,10 @@ func (widget *Widget) contentFrom(valueRanges []*sheets.ValueRange) string {
|
||||
return "error 1"
|
||||
}
|
||||
|
||||
valuesColor := Config.UString("wtf.mods.gspreadsheets.colors.values", "green")
|
||||
valuesColor := wtf.Config.UString("wtf.mods.gspreadsheets.colors.values", "green")
|
||||
res := ""
|
||||
|
||||
cells := wtf.ToStrs(Config.UList("wtf.mods.gspreadsheets.cells.names"))
|
||||
cells := wtf.ToStrs(wtf.Config.UList("wtf.mods.gspreadsheets.cells.names"))
|
||||
for i := 0; i < len(valueRanges); i++ {
|
||||
res = res + fmt.Sprintf("%s\t[%s]%s\n", cells[i], valuesColor, valueRanges[i].Values[0][0])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user